Что-то вы гоните насчет "привычного вида формата 755 и 644". Я вот вообще не понял что это!😳
Действительно, что означают цифры которые мы получили в прошлом посте?
Это кодировка, заключающая в себе режимы доступа к файлу.
Подробней можно почитать в статье про chmod.
Там можно увидеть альтернативное обозначение того же самого с помощью символов r w x, что значит чтение, запись, исполнение.
Чтобы преобразовать восьмеричное число в такое обозначение в Python есть готовая функция
>>> stat.filemode(0o755)
'?rwxr-xr-x'
Мы видим 3 группы по 3 символа, дающие 3 типа доступа для 3 типов юзеров.
А что за знак вопроса в начале?
Давайте передадим в эту функцию необрезанное значение от os.stat
>>> stat.filemode(os.stat(path).st_mode)
'drwxr-xr-x'
Это данные, которые мы безжалостно обрезали в прошлый раз😼
Первый символ обозначает тип объекта. Это может быть файл (-), директория (d) или симлинк (l).
Вот простая схема данной кодировки
[1][3][3][3]
│ │ │ │
│ │ │ └──> Others Permissions
│ │ └─────> Group Permissions
│ └────────> Owner Permissions
└───────────> File Type
(разверните экран если вы с телефона)
Если вы попробуете получить пермишены для симлинка то получите пермишены для файла
>>> path = '.venv/bin/python3'
>>> stat.filemode(os.stat(path).st_mode)
'-rwxr-xr-x'
Чтобы получить свойства именно симлинка, нужно это явно указать
>>> stat.filemode(os.stat(path, follow_symlinks=False).st_mode)
'lrwxrwxrwx'
#tricks#basic
Hobbs ripped as 'total disgrace' after vetoing bill limiting Chinese land ownership near military bases https://www.foxnews.com/politics/dem-governor-ripped-total-disgrace-after-vetoing-bill-limiting-chinese-land-ownership-near-military-bases#FoxNews
At least one dead after jet crashes into another plane at Scottsdale Airport in Arizona https://www.foxnews.com/us/least-one-dead-after-jet-crashes-another-plane-scottsdale-airport-arizona#FoxNews
🔻 Biden accused of ‘moving goalposts’ on percentage of Americans who need to get jab to return normal https://t.co/LzJxFI3CdG#FoxNews
September 29, 2021 at 04:45PM
via Twitter
@SenTedCruz
🔻 Border Patrol agents see 3,166% increase in convicted sex offender arrests in Del Rio Sector https://t.co/9X50ziXFYK#FoxNews
June 25, 2021 at 12:30AM
via Twitter
@SenTedCruz
#newtgingrich : RT @MariaBartiromo: Rep. Kevin McCarthy on debt ceiling talks: 'I will never give up' https://t.co/BRZg1fPCs7#FoxNews@SundayFutures@FoxBusiness
#newtgingrich : RT @MariaBartiromo: Trafalgar Group pollster Robert Cahaly predicts 'strong night' for Republicans https://t.co/Zttn6XkTOA#FoxNews@SundayFutures@FoxNews
#newtgingrich : RT @MariaBartiromo: Herschel Walker rips Warnock's lack of business experience: 'He never built anything' https://t.co/uprZBwsrTK#FoxNews@SundayFutures@FoxNews
#newtgingrich : RT @MariaBartiromo: Rep. Kevin McCarthy cites 'cost of living' as top priority for voters ahead of midterms https://t.co/0gukhkMjkr#FoxNews@SundayFutures@FoxNews
¿Lo de #RochaMoya es político? 🤔
🔴 La zar antidrogas de #EU reconoció en #FoxNews las acciones del gobierno de #Sheinbaum para combatir el narcotráfico 📺🇲🇽👏🏻
https://sinlineamx.com/eu-reconoce-eficiencia-gobierno-sheinbaum-combate-narco/