Как правильно проверить атрибуты доступа файла? То есть доступна ли запись в файл или является ли он исполняемым?
Для этого в Python есть функция os.access()
Проверять так:
os.access(path, flag)
Функция вернёт bool в зависимости от наличия указанного флага.
Всего есть 4 флага проверки:
os.F_OK - наличие файла на диске
os.R_OK - доступ на чтение
os.W_OK - доступ на запись
os.X_OK - доступ на исполнение
Например, вместо try-except лучше делать так (пример из документации):
if os.access("myfile", os.R_OK):
with open("myfile") as fp:
return fp.read()
#basic#libs
Bliss - Official | Android 15 | Nothing Phone (2)
✍️ Details:
- Version: 18.5
- Codename: #Pong
- Released: 21/4/25
🔽Download:Vanilla | Vanilla(Mirror) (Recovery Build)
🆘 Support : Here
⚙️ Installation: Here
📸 Screenshots: Here
🔖 Tags : #ROM#AOSP#Official#Bliss#V
✨ ChangelogsROM | Device
✍️ Note:
- Vanilla only
- clean flash recommended
- you can use this gapps: here, or flash your choice of gapps/microg if you know what you're doing
- ksu disabled bcs of official requirements
🏆 Credits
- @Ghosuto7 for DT
- Hellboy for Meteoric kernel
- Fabian for PA Glyph Implementation
- Testers
😎 Maintainer : @Drishal
🔔 Updates : @NothingPhone2Updates
💬 Chat : @NothingPhone2
Bliss - Official | Android 15 | Nothing Phone (2)
✍️ Details:
- Version: 18.2
- Codename: #Pong
- Released: 29/1/25
🔽 Download: [ Vanilla | Gapps ] (Recovery Build)
🆘 Support : Here
⚙️ Installation: Here
📸 Screenshots: Here
✨ Source Changelogs: Here
🔖 Tags : #ROM#AOSP#Official#Bliss#V
✨ Changelogs
- Update to NOS V3.0-250113-1723 firmware
- Improvements to system performance and stability
✍️ Note:
- Both Gapps and Vanilla build available
🏆 Credits
- Chandu for base DT
- Hellboy for Meteoric kernel
- Fabian for PA Glyph Implementation
- Testers
- Note: bliss is not patched with ksu due to official requirements
😎 Maintainer : @Drishal
🔔 Updates : @NothingPhone2Updates
💬 Chat : @NothingPhone2