Что-то вы гоните насчет "привычного вида формата 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
Embark on a journey of progress and transformation! 🚀
Visit https://9years.mygov.in/ to discover the incredible achievements of the Modi Government in the last 9 years. Explore the remarkable strides made across various sectors, from healthcare to infrastructure, education to governance.
#9YearsOfSeva
🇮🇳 In 9 years, the Modi Government achieved an unprecedented combination of speed and scale, ensuring the timely completion of all projects!
From highways and airports to digital infrastructure, India witnessed an era of efficient governance that propelled progress at an unmatched pace.
#9YearsOfSeva
https://youtu.be/L7x-8aIjSQ0
"सेवा, सुशासन और गरीब कल्याण को सर्मपित 9️⃣ साल" 🇮🇳
आइए इस वीडियों के माध्यम से देखें कैसे, बीते 9 वर्षों में #NewIndia जनसामान्य की आकांक्षाओं को पूरा करते हुए निरन्तर नई-नई उपलब्धियां रच रहा है।
#9YearsOfSeva
https://youtu.be/L7x-8aIjSQ0
"सेवा, सुशासन और गरीब कल्याण को सर्मपित 9️⃣ साल" 🇮🇳
आइए इस वीडियों के माध्यम से देखें कैसे, बीते 9 वर्षों में #NewIndia जनसामान्य की आकांक्षाओं को पूरा करते हुए निरन्तर नई-नई उपलब्धियां रच रहा है।
#9YearsOfSeva
https://youtu.be/L7x-8aIjSQ0
बीते 9 वर्षों में माननीय प्रधानमंत्री #NarendraModi के नेतृत्व में केंद्र सरकार द्वारा विभिन्न क्षेत्रों में हुई अविश्वसनीय उपलब्धियों को जानने हेतु अभी विजिट करेः https://9years.mygov.in/
#9YearsOfSeva
Don't miss this remarkable video showcasing how the Modi government's relentless efforts over the past 9 years have propelled the development and preservation of India's rich cultural heritage.
Visit: https://youtu.be/scGbw2m8ook
#9YearsOfPreservingCulture
#9YearsOfSeva
Check out this captivating snapshot showcasing the Modi government's remarkable progress in preserving and promoting India's cultural heritage. From restoring ancient monuments to revitalizing traditional arts, their efforts over the past 9 years have made India's legacy shine brighter than ever.
#9YearsOfPreservingCulture
#9YearsOfSeva
📈 India keeps dominating the digital payment landscape! 💸🇮🇳 With innovative solutions and widespread adoption, we're leading the way towards a cashless economy. 💻
#9YearsOfTechForGrowth#9YearsOfSeva
Empowering street vendors for a brighter future!
PM SVANidhi is transforming lives & livelihoods, providing financial support, & fostering entrepreneurship among street vendors in India
#9YearsOfGaribKalyan#9YearsOfSeva
Check out this captivating snapshot showcasing the incredible strides made in environment and sustainability during the 9 years of the Modi government.
#9YearsOfSustainableGrowth#9YearsOfSeva