Файловый менеджер - Редактировать - /var/www/html/platformdirs.zip
Ðазад
PK ! ��؋� � android.pynu �[��� from __future__ import annotations import os import re import sys from functools import lru_cache from .api import PlatformDirsABC class Android(PlatformDirsABC): """ Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>` and `version <platformdirs.api.PlatformDirsABC.version>`. """ @property def user_data_dir(self) -> str: """:return: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``""" return self._append_app_name_and_version(_android_folder(), "files") @property def site_data_dir(self) -> str: """:return: data directory shared by users, same as `user_data_dir`""" return self.user_data_dir @property def user_config_dir(self) -> str: """ :return: config directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>`` """ return self._append_app_name_and_version(_android_folder(), "shared_prefs") @property def site_config_dir(self) -> str: """:return: config directory shared by the users, same as `user_config_dir`""" return self.user_config_dir @property def user_cache_dir(self) -> str: """:return: cache directory tied to the user, e.g. e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>``""" return self._append_app_name_and_version(_android_folder(), "cache") @property def user_state_dir(self) -> str: """:return: state directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @property def user_log_dir(self) -> str: """ :return: log directory tied to the user, same as `user_cache_dir` if not opinionated else ``log`` in it, e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/log`` """ path = self.user_cache_dir if self.opinion: path = os.path.join(path, "log") return path @property def user_documents_dir(self) -> str: """ :return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents`` """ return _android_documents_folder() @property def user_runtime_dir(self) -> str: """ :return: runtime directory tied to the user, same as `user_cache_dir` if not opinionated else ``tmp`` in it, e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/tmp`` """ path = self.user_cache_dir if self.opinion: path = os.path.join(path, "tmp") return path @lru_cache(maxsize=1) def _android_folder() -> str: """:return: base folder for the Android OS""" try: # First try to get path to android app via pyjnius from jnius import autoclass Context = autoclass("android.content.Context") # noqa: N806 result: str = Context.getFilesDir().getParentFile().getAbsolutePath() except Exception: # if fails find an android folder looking path on the sys.path pattern = re.compile(r"/data/(data|user/\d+)/(.+)/files") for path in sys.path: if pattern.match(path): result = path.split("/files")[0] break else: raise OSError("Cannot find path to android app folder") return result @lru_cache(maxsize=1) def _android_documents_folder() -> str: """:return: documents folder for the Android OS""" # Get directories with pyjnius try: from jnius import autoclass Context = autoclass("android.content.Context") # noqa: N806 Environment = autoclass("android.os.Environment") # noqa: N806 documents_dir: str = Context.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath() except Exception: documents_dir = "/storage/emulated/0/Documents" return documents_dir __all__ = [ "Android", ] PK ! ��kU� � __main__.pynu �[��� from __future__ import annotations from pip._vendor.platformdirs import PlatformDirs, __version__ PROPS = ( "user_data_dir", "user_config_dir", "user_cache_dir", "user_state_dir", "user_log_dir", "user_documents_dir", "user_runtime_dir", "site_data_dir", "site_config_dir", ) def main() -> None: app_name = "MyApp" app_author = "MyCompany" print(f"-- platformdirs {__version__} --") print("-- app dirs (with optional 'version')") dirs = PlatformDirs(app_name, app_author, version="1.0") for prop in PROPS: print(f"{prop}: {getattr(dirs, prop)}") print("\n-- app dirs (without optional 'version')") dirs = PlatformDirs(app_name, app_author) for prop in PROPS: print(f"{prop}: {getattr(dirs, prop)}") print("\n-- app dirs (without optional 'appauthor')") dirs = PlatformDirs(app_name) for prop in PROPS: print(f"{prop}: {getattr(dirs, prop)}") print("\n-- app dirs (with disabled 'appauthor')") dirs = PlatformDirs(app_name, appauthor=False) for prop in PROPS: print(f"{prop}: {getattr(dirs, prop)}") if __name__ == "__main__": main() PK ! �줕� � $ __pycache__/__main__.cpython-310.pycnu �[��� o !��h� � @ s@ d dl mZ d dlmZmZ dZd dd�Zedkre� d S d S )� )�annotations)�PlatformDirs�__version__) � user_data_dir�user_config_dir�user_cache_dir�user_state_dir�user_log_dir�user_documents_dir�user_runtime_dir� site_data_dir�site_config_dir�return�Nonec C s� d} d}t dt� d�� t d� t| |dd�}tD ]}t |� dt||�� �� qt d � t| |�}tD ]}t |� dt||�� �� q3t d � t| �}tD ]}t |� dt||�� �� qLt d� t| dd �}tD ]}t |� dt||�� �� qgd S )N�MyApp� MyCompanyz-- platformdirs z --z%-- app dirs (with optional 'version')z1.0)�versionz: z) -- app dirs (without optional 'version')z+ -- app dirs (without optional 'appauthor')z( -- app dirs (with disabled 'appauthor')F)� appauthor)�printr r �PROPS�getattr)�app_name� app_author�dirs�prop� r �C/usr/lib/python3/dist-packages/pip/_vendor/platformdirs/__main__.py�main s( �r �__main__N)r r )� __future__r �pip._vendor.platformdirsr r r r �__name__r r r r �<module> s �PK ! ��f� � # __pycache__/android.cpython-310.pycnu �[��� o !��h� � @ s~ d dl mZ d dlZd dlZd dlZd dlmZ ddlmZ G dd� de�Z edd�ddd��Z edd�dd d��ZdgZdS )� )�annotationsN)� lru_cache� )�PlatformDirsABCc @ s� e Zd ZdZeddd��Zeddd��Zeddd ��Zedd d��Zeddd ��Z eddd��Z eddd��Zeddd��Zeddd��Z dS )�Androidz� Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>` and `version <platformdirs.api.PlatformDirsABC.version>`. �return�strc C � | � t� d�S )zd:return: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``�files��_append_app_name_and_version�_android_folder��self� r �B/usr/lib/python3/dist-packages/pip/_vendor/platformdirs/android.py� user_data_dir � zAndroid.user_data_dirc C � | j S )z@:return: data directory shared by users, same as `user_data_dir`�r r r r r � site_data_dir � zAndroid.site_data_dirc C r )z :return: config directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>`` �shared_prefsr r r r r �user_config_dir s zAndroid.user_config_dirc C r )zH:return: config directory shared by the users, same as `user_config_dir`)r r r r r �site_config_dir# r zAndroid.site_config_dirc C r )zj:return: cache directory tied to the user, e.g. e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>``�cacher r r r r �user_cache_dir( r zAndroid.user_cache_dirc C r )zB:return: state directory tied to the user, same as `user_data_dir`r r r r r �user_state_dir- r zAndroid.user_state_dirc C � | j }| jr tj�|d�}|S )z� :return: log directory tied to the user, same as `user_cache_dir` if not opinionated else ``log`` in it, e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/log`` �log�r �opinion�os�path�join�r r# r r r �user_log_dir2 � zAndroid.user_log_dirc C s t � S )zf :return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents`` )�_android_documents_folderr r r r �user_documents_dir= s zAndroid.user_documents_dirc C r )z� :return: runtime directory tied to the user, same as `user_cache_dir` if not opinionated else ``tmp`` in it, e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/tmp`` �tmpr r% r r r �user_runtime_dirD r'