Package: cengal-app-dir-path-finder
CengalAppDirPathFinderCengalAppDirPathFinder is a cross-platform Python module designed to simplify the process of locating OS-recommended directories for application data, cache, logs, and more. It seamlessly integrates with Windows, Linux, and macOS, utilizing platform-specific standards likeKNOWNFOLDERID constantson Windows,XDG standardson Linux, andNSSearchPathForDirectoriesInDomainson macOS. This module offers a unified API for accessing various types of directories, such as local, roaming, and program-specific paths, enhancing application compatibility and data management across different operating systems.Installationpipinstallcengal_app_dir_path_finderDocumentationImportfromcengal_app_dir_path_finderimportAppDirectoryType,AppDirPathUsageimportosfromcengal_app_dir_path_finderimportAppDirectoryType,AppDirPathapp_dir_path:AppDirPath=AppDirPath()local_data_dir_path:str=app_dir_path(AppDirectoryType.local_data,'MyApplicationName')settings_json_path:str=os.path.join(local_data_dir_path,'settings.json')withopen(settings_json_path,'w')asfile:file.write(my_app_settings)Supported foler typesAppDirectoryTypeis an enum of all supported kinds of directories.AppDirectoryTypeFields:local_data: Local user-specific data storage, not shared across users, ideal for storing user preferences, game scores, etc.local_low_data: Low privilege local data storage for sandboxed or security-sensitive applications.roaming_data: User-specific data that may sync across devices, suitable for configurations and settings.local_cache: Stores temporary, user-specific cache data that can be regenerated as needed.local_low_cache: Similar to local_cache but for applications requiring lower access privileges.roaming_cache: User-specific cache data that could be shared and synced across devices.local_temp: Temporary files and data specific to the current user.local_low_temp: Temporary files for applications with lower privileges.roaming_temp: Temporary user-specific files that might be synced across devices.local_log: Logs and operation records for the current user.local_low_log: Logs for low privilege applications.roaming_log: User-specific logs that might be shared across devices.local_config: Configuration files and settings for the current user.local_low_config: Configuration for applications with lower privileges.roaming_config: Configurations that might be synced across a user's devices.local_runtime: User-specific runtime data like sockets and named pipes.local_low_runtime: Runtime data for applications with lower privileges.roaming_runtime: User-specific runtime data that could be synced across devices.program_files: Static data shared among all users, like application binaries.program_files_common: Shared libraries and common resources for multiple applications.program_data: Non-static data shared among users, like shared databases.program_cache: Cache for shared applications and services.program_temp: Temporary files for shared applications.program_log: Log files for system-wide applications.program_config: Configuration files for system-wide applications.program_runtime: System-wide runtime data like global sockets and named pipes.user_profile_data: User-specific application data within the user's home directory.user_profile_program_files: Static data specific to user-installed applications.user_profile_program_files_common: Shared resources for user-specific applications.local_static_data: Static data specific to the local user, not frequently modified.local_low_static_data: Static data for lower privilege user applications.roaming_static_data: User-specific static data that may sync across devices.program_static_data: Static data shared among all users and applications.AppDirPath methods__call__(...)def __call__(self, dir_type: AppDirectoryType, app_name_or_path: DirNameOrPath, with_structure: bool = True, ensure_dir: bool = True) -> str:Constructs path of the requestet directory type taking into account provided application name.with_structure:False: determines base directory provided by OS and followed with an application nameTrue: determines base directory provided by OS, followed with an application name and completed with a suffixes like 'cache', 'config', 'log', etc.ensure_dir:True: creates directory sequence if does not existscached(...)def cached(self, dir_type: AppDirectoryType, app_name_or_path: DirNameOrPath, with_structure: bool = True, ensure_dir: bool = True) -> str:Cached version. Much faster in a repetitive requests.Global app instances of AppDirPathAnInstanceservice from theCengal.Coroutinesholds globally accessible instance of the AppDirPath as well as globally acessible field for an application name:{...'app_name':str(),'app_name_for_fs':str(),'app_version':tuple(),'app_version_str':str(),AppDirPath:AppDirPath(),'app_data_dir_path_type':AppDirectoryType.local_data,'app_cache_dir_path_type':AppDirectoryType.local_cache,'app_temp_dir_path_type':AppDirectoryType.local_temp,'app_log_dir_path_type':AppDirectoryType.local_log,'app_config_dir_path_type':AppDirectoryType.local_config,'app_runtime_dir_path_type':AppDirectoryType.local_runtime,...}SeveralCengal.Coroutines.Servicesusing these fields and instances in their work. For example such services asdb(async LMDB) andlog.Short example of proper usage:fromcengal_app_dir_path_finderimportAppDirectoryType,AppDirPathfromcengal.parallel_execution.coroutines.coro_schedulerimportcs_acorofromcengal.parallel_execution.coroutines.coro_standard_services.instanceimportafast_wait,fast_get,fast_setfromuuidimportuuid4MY_APP_CONFIGURATION_COMPLETED_FLAG_NAME:str=f'My Application Mandatory Configuration Complited{uuid4()}'@cs_acoroasyncdefset_app_name(app_name:str)->None:fast_set('app_name_for_fs',app_name)fast_set(MY_APP_CONFIGURATION_COMPLETED_FLAG_NAME,None)@cs_acoroasyncdefget_local_temp_dir()->str:awaitafast_wait(MY_APP_CONFIGURATION_COMPLETED_FLAG_NAME)app_dir_path:AppDirPath=fast_get(AppDirPath)returnapp_dir_path.cached(fast_get('app_temp_dir_path_type'),fast_get('app_name_for_fs'))Same example but a bit faster in an execution performance terms:fromcengal.file_system.app_fs_structure.app_dir_pathimportAppDirectoryType,AppDirPath# totaly the same import as in a previous examplefromcengal.parallel_execution.coroutines.coro_schedulerimportInterfacefromcengal.parallel_execution.coroutines.coro_standard_services.instanceimportafast_wait_explicit,fast_get_explicit,fast_set_explicitfromuuidimportuuid4MY_APP_CONFIGURATION_COMPLETED_FLAG_NAME:str=f'My Application Mandatory Configuration Complited{uuid4()}'asyncdefset_app_name(i:Interface,app_name:str)->None:fast_set_explicit(i,'app_name_for_fs',app_name)fast_set_explicit(i,MY_APP_CONFIGURATION_COMPLETED_FLAG_NAME,None)asyncdefget_local_temp_dir(i:Interface)->str:awaitafast_wait_explicit(i,MY_APP_CONFIGURATION_COMPLETED_FLAG_NAME)app_dir_path:AppDirPath=fast_get_explicit(i,AppDirPath)returnapp_dir_path.cached(fast_get_explicit(i,'app_temp_dir_path_type'),fast_get_explicit(i,'app_name_for_fs'))Based on CengalRepresents part of Cengal library:https://pypi.org/project/cengal/https://github.com/FI-Mihej/CengalAn equivalent import:fromcengal.file_system.app_fs_structure.app_dir_pathimportAppDirectoryType,AppDirPathCengal library can be installed by:pipinstallcengalProjects using Cengalflet_async- wrapper which makesFletasync and brings booth Cengal.coroutines and asyncio to Flet (Flutter based UI)justpy_containers- wrapper aroundJustPyin order to bring more security and more production-needed features to JustPy (VueJS based UI)Bensbach- decompiler from Unreal Engine 3 bytecode to a Lisp-like script and compiler back to Unreal Engine 3 bytecode. Made for a game modding purposesRealistic-Damage-Model-mod-for-Long-War- Mod for both the original XCOM:EW and the mod Long War. Was made with a Bensbach, which was made with CengalSmartCATaloguer.com- TagDB based catalog of images (tags), music albums (genre tags) and apps (categories)LicenseCopyright © 2012-2023 ButenkoMS. All rights reserved.Licensed under the Apache License, Version 2.0.