cai.storage package¶
Application Storage Manager
This module is used to manage application storage.
- Copyright
Copyright (C) 2021-2021 cscs181
- License
AGPL-3.0 or later. See LICENSE for detail.
- class cai.storage.Storage¶
基类:
object- app_name: str = 'CAI'¶
- default_app_dir: str = '/home/docs/.config/CAI'¶
- app_dir: str = '/home/docs/.config/CAI'¶
- default_cache_dir: str = '/home/docs/.cache/CAI'¶
- cache_dir: str = '/home/docs/.cache/CAI'¶
- device_file: str = '/home/docs/.config/CAI/device.json'¶
- protocol_env_name: str = 'CAI_PROTOCOL'¶
- protocol_file: str = '/home/docs/.config/CAI/protocol'¶
- classmethod clear_cache()¶
Submodules¶
cai.storage.utils module¶
This code was taken from https://github.com/python-poetry/poetry/blob/master/poetry/utils/appdirs.py
- cai.storage.utils.expanduser(path)¶
Expand ~ and ~user constructions. Includes a workaround for http://bugs.python.org/issue14768
- cai.storage.utils.user_cache_dir(appname)¶
- Return full path to the user-specific cache dir for this application.
“appname” is the name of application.
- Typical user cache directories are:
macOS:
~/Library/Caches/<AppName>Unix:~/.cache/<AppName>(XDG default) Windows:C:\Users\<username>\AppData\Local\<AppName>\Cache
On Windows the only suggestion in the MSDN docs is that local settings go in the
CSIDL_LOCAL_APPDATAdirectory. This is identical to the non-roaming app data dir (the default returned byuser_data_dir()). Apps typically put cache data somewhere under the given dir here. Some .. rubric:: Examples...\Mozilla\Firefox\Profiles\<ProfileName>\Cache...\Acme\SuperApp\Cache\1.0OPINION: This function appends “Cache” to the
CSIDL_LOCAL_APPDATAvalue.
- cai.storage.utils.user_data_dir(appname, roaming=False)¶
Return full path to the user-specific data dir for this application.
“appname” is the name of application. If None, just the system directory is returned.
“roaming” (boolean, default False) can be set True to use the Windows roaming appdata directory. That means that for users on a Windows network setup for roaming profiles, this user data will be sync’d on login. See <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx> for a discussion of issues.
- Typical user data directories are:
macOS:
~/Library/Application Support/<AppName>Unix:~/.local/share/<AppName>or in $XDG_DATA_HOME, if defined Win XP (not roaming):C:\Documents and Settings\<username>\Application Data\<AppName>Win XP (roaming):C:\Documents and Settings\<username>\Local Settings\Application Data\<AppName>Win 7 (not roaming):C:\Users\<username>\AppData\Local\<AppName>Win 7 (roaming):C:\Users\<username>\AppData\Roaming\<AppName>
For Unix, we follow the XDG spec and support $XDG_DATA_HOME. That means, by default “~/.local/share/<AppName>”.
- cai.storage.utils.user_config_dir(appname, roaming=True)¶
Return full path to the user-specific config dir for this application.
“appname” is the name of application. If None, just the system directory is returned.
“roaming” (boolean, default True) can be set False to not use the Windows roaming appdata directory. That means that for users on a Windows network setup for roaming profiles, this user data will be sync’d on login. See <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx> for a discussion of issues.
- Typical user data directories are:
macOS: same as user_data_dir Unix:
~/.config/<AppName>Win *: same as user_data_dir
For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME. That means, by default “~/.config/<AppName>”.
- cai.storage.utils.site_config_dirs(appname)¶
Return a list of potential user-shared config dirs for this application.
“appname” is the name of application.
- Typical user config directories are:
macOS:
/Library/Application Support/<AppName>/Unix:/etc or $XDG_CONFIG_DIRS[i]/<AppName>/for each value in $XDG_CONFIG_DIRS Win XP:C:\Documents and Settings\All Users\Application Data\<AppName>\Vista: (Fail! “C:ProgramData” is a hidden system directory on Vista.) Win 7: Hidden, but writeable on Win 7C:\ProgramData\<AppName>\