Что-то вы гоните насчет "привычного вида формата 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
#HawkerHeritage📢 Originally the Seng Poh Road Market in 1951, Tiong Bahru Market served as a bustling centre for the community. Next time you’re there for a meal, don’t forget to soak up the history & nostalgia!
#OurHawkerCulture#OurHawkerCentres
#HawkerHeritage Fancy A Feast in a Garden 🌴? Since 1971, Newton Food Centre hawker has been serving up Singapore’s culinary diversity with its unique 'garden city' charm. Forward this post to someone who’ll appreciate this picturesque setting!
#OurHawkerCulture#OurHawkerCentres#HawkerHeritage
#HawkerHeritage📜 Tekka Centre: Let’s time-travel back to 1915, where 'Kandang Kerbau' and ‘Tekka’ tell tales of cattle and wild bamboo. What a journey for the senses!
#OurHawkerCulture#OurHawkerCentres
#HawkerHeritage🌟 People’s Park Food Centre: A Culinary Heritage Site 🌟 Starting as a hawker shelter in 1923 and evolving into the largest market by 1940, it's a place where history and cuisine meet. Share this with someone that you’ll like to explore this iconic food haven with!
#OurHawkerCulture#OurHawkerCentres
#HawkerHeritage🍲✨ Experience a rich blend of history and culinary excellence at Singapore's largest hawker centre: Chinatown Complex Market! Established in 1981 for the last of Chinatown’s street hawkers, it's now a vibrant gastronomic haven with around 700 stalls. Share this with your favourite foodies!
#OurHawkerCulture#OurHawkerCentres
#HawkerHeritage Changi Village Hawker Centre: From a military past to a seaside food haunt 🌴#DidYouKnow This dining spot was part of Changi's transformation into a resort? An idyllic memory to savour with your favourite hawker delights!
#OurHawkerCulture#OurHawkerCentres
#HawkerHeritage Architectural elegance meets culinary delight at Old Airport Road Food Centre 🍴🏛️#DidYouKnow that its modern structure was designed in '73 to match the housing estates in the area?
#OurHawkerCulture#OurHawkerCentres
#HawkerHeritage#DidYouKnow Adam Road Food Centre is nine-sided and almost circular? This popular spot is famous for its nasi lemak and a variety of delightful treats! This is your sign to organise that makan trip🍴
#OurHawkerCulture#OurHawkerCentres
❤️#HawkerHeritage❤️#DidYouKnow that Maxwell Food Centre was once a wet market? It was also one of the places where the poor and displaced could find cheap meals after WWII. Today, it’s a treasure trove of local delights!
#OurHawkerCulture#OurHawkerCentres