riptable.Utils.appdirs
Utilities for determining application-specific dirs.
See <http://github.com/ActiveState/appdirs> for details and usage.
Classes
Convenience wrapper for getting application dirs. |
Functions
|
This is a fallback technique at best. I'm not sure if using the |
|
|
|
|
|
|
|
Return full path to the user-shared data dir for this application. |
|
Return full path to the user-shared data dir for this application. |
|
Return full path to the user-specific cache dir for this application. |
|
Return full path to the user-specific config dir for this application. |
|
Return full path to the user-specific data dir for this application. |
|
Return full path to the user-specific log dir for this application. |
|
Return full path to the user-specific state dir for this application. |
Attributes
- class riptable.Utils.appdirs.AppDirs(appname=None, appauthor=None, version=None, roaming=False, multipath=False)
Bases:
object
Convenience wrapper for getting application dirs.
- property site_config_dir
- property site_data_dir
- property user_cache_dir
- property user_config_dir
- property user_data_dir
- property user_log_dir
- property user_state_dir
- riptable.Utils.appdirs._get_win_folder_from_registry(csidl_name)
This is a fallback technique at best. I’m not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
- riptable.Utils.appdirs._get_win_folder_with_ctypes(csidl_name)
- riptable.Utils.appdirs._get_win_folder_with_jna(csidl_name)
- riptable.Utils.appdirs._get_win_folder_with_pywin32(csidl_name)
- riptable.Utils.appdirs.site_config_dir(appname=None, appauthor=None, version=None, multipath=False)
Return full path to the user-shared data dir for this application.
Typical site config directories are:
Mac OS X: same as
site_data_dir
Unix:
/etc/xdg/<AppName>
or$XDG_CONFIG_DIRS[i]/<AppName>
for each value in$XDG_CONFIG_DIRS
Win: same as
site_data_dir
Vista: (Fail!
"C:\ProgramData"
is a hidden system directory on Vista.)
For Unix, this is using the
$XDG_CONFIG_DIRS[0]
default, ifmultipath=False
.Warning
Do not use this on Windows. See the Vista-Fail note above for why.
- Parameters:
appname – The name of application. If None, just the system directory is returned.
appauthor – Only used on Windows. The name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to
appname
. You may passFalse
to disable it.version – An optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be
"<major>.<minor>"
. Only applied whenappname
is present.multipath (bool, default False) – An optional parameter only applicable to Unix-like operating systems that indicates that the entire list of config dirs should be returned. By default, the first item from
XDG_CONFIG_DIRS
is returned, or'/etc/xdg/<AppName>'
, ifXDG_CONFIG_DIRS
is not set.
- riptable.Utils.appdirs.site_data_dir(appname=None, appauthor=None, version=None, multipath=False)
Return full path to the user-shared data dir for this application.
Typical site data directories are:
Mac OS X:
/Library/Application Support/<AppName>
Unix:
/usr/local/share/<AppName>
or/usr/share/<AppName>
Win XP:
C:\Documents and Settings\All Users\Application Data\<AppAuthor>\<AppName>
Vista: (Fail!
"C:\ProgramData"
is a hidden system directory on Vista.)Win 7:
C:\ProgramData\<AppAuthor>\<AppName>
(Hidden, but writeable on Win 7.)
For Unix, this is using the
$XDG_DATA_DIRS[0]
default.- Parameters:
appname – The name of application. If None, just the system directory is returned.
appauthor – Only used on Windows. The name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to
appname
. You may passFalse
to disable it.version – An optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be
"<major>.<minor>"
. Only applied whenappname
is present.multipath (bool, default False) – An optional parameter only applicable to Unix-like operating systems that indicates that the entire list of data dirs should be returned. By default, the first item from
XDG_DATA_DIRS
is returned, or'/usr/local/share/<AppName>'
ifXDG_DATA_DIRS
is not set.
Warning
Do not use this on Windows. See the Vista-Fail note above for why.
- riptable.Utils.appdirs.user_cache_dir(appname=None, appauthor=None, version=None, opinion=True)
Return full path to the user-specific cache dir for this application.
Typical user cache directories are:
Mac OS X:
~/Library/Caches/<AppName>
Unix:
~/.cache/<AppName>
(XDG default)Win XP:
C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Cache
Vista:
C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Cache
On Windows the only suggestion in the MSDN docs is that local settings go in the
CSIDL_LOCAL_APPDATA
directory. This is identical to the non-roaming app data dir (the default returned byuser_data_dir
above). Apps typically put cache data somewhere under the given dir here. Some examples:...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
...\Acme\SuperApp\Cache\1.0
OPINION: This function appends “Cache” to the
CSIDL_LOCAL_APPDATA
value. This can be disabled with theopinion=False
option.- Parameters:
appname – The name of application. If None, just the system directory is returned.
appauthor – Only used on Windows. The name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to
appname
. You may passFalse
to disable it.version – An optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be
"<major>.<minor>"
. Only applied when appname is present.opinion (bool, default True) – Can be
False
to disable the appending of “Cache” to the base app data dir for Windows. See discussion above.
- riptable.Utils.appdirs.user_config_dir(appname=None, appauthor=None, version=None, roaming=False)
Return full path to the user-specific config dir for this application.
Typical user config directories are:
Mac OS X:
~/Library/Preferences/<AppName>
Unix:
~/.config/<AppName>
or in$XDG_CONFIG_HOME
, if definedWin: same as
user_data_dir
For Unix, we follow the XDG spec and support
$XDG_CONFIG_HOME
. That means~/.config/<AppName>
by default.- Parameters:
appname – The name of application. If None, just the system directory is returned.
appauthor – Only used on Windows. The name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to
appname
. You may passFalse
to disable it.version – An optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be
"<major>.<minor>"
. Only applied whenappname
is present.roaming (bool, 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 Microsoft’s Managing Roaming User Data Deployment Guide for a discussion of issues.
- riptable.Utils.appdirs.user_data_dir(appname=None, appauthor=None, version=None, roaming=False)
Return full path to the user-specific data dir for this application.
Typical user data directories are:
Mac OS X:
~/Library/Application Support/<AppName>
Unix:
~/.local/share/<AppName>
or in$XDG_DATA_HOME
, if definedWin XP (not roaming):
C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
Win XP (roaming):
C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
Win 7 (not roaming):
C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>
Win 7 (roaming):
C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>
For Unix, we follow the XDG spec and support
$XDG_DATA_HOME
. That means~/.local/share/<AppName>
by default .- Parameters:
appname – The name of application. If None, just the system directory is returned.
appauthor – Only used on Windows. The name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to
appname
. You may passFalse
to disable it.version – An optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be
"<major>.<minor>"
. Only applied whenappname
is present.roaming (bool, 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 Microsoft’s Managing Roaming User Data Deployment Guide for a discussion of issues.
- riptable.Utils.appdirs.user_log_dir(appname=None, appauthor=None, version=None, opinion=True)
Return full path to the user-specific log dir for this application.
Typical user log directories are:
Mac OS X:
~/Library/Logs/<AppName>
Unix:
~/.cache/<AppName>/log
or under$XDG_CACHE_HOME
if definedWin XP:
C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Logs
Vista:
C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Logs
On Windows the only suggestion in the MSDN docs is that local settings go in the
CSIDL_LOCAL_APPDATA
directory. (Note: I’m interested in examples of what some windows apps use for a logs dir.)OPINION: This function appends “Logs” to the
CSIDL_LOCAL_APPDATA
value for Windows and appends “log” to the user cache dir for Unix. This can be disabled with theopinion=False
option.- Parameters:
appname – The name of application. If None, just the system directory is returned.
appauthor – Only used on Windows. The name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to
appname
. You may passFalse
to disable it.version – An optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be
"<major>.<minor>"
. Only applied whenappname
is present.opinion (bool, default True) – Can be
False
to disable the appending of “Logs” to the base app data dir for Windows, and “log” to the base cache dir for Unix. See discussion above.
- riptable.Utils.appdirs.user_state_dir(appname=None, appauthor=None, version=None, roaming=False)
Return full path to the user-specific state dir for this application.
Typical user state directories are:
Mac OS X: same as
user_data_dir
Unix:
~/.local/state/<AppName>
or in$XDG_STATE_HOME
, if definedWin: same as
user_data_dir
For Unix, we follow this Debian proposal to extend the XDG spec and support
$XDG_STATE_HOME
. That means~/.local/state/<AppName>
by default.- Parameters:
appname – The name of application. If None, just the system directory is returned.
appauthor – Only used on Windows. The name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to
appname
. You may passFalse
to disable it.version – An optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be
"<major>.<minor>"
. Only applied whenappname
is present.roaming (bool, 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 Microsoft’s Managing Roaming User Data Deployment Guide for a discussion of issues.
- riptable.Utils.appdirs.PY3
- riptable.Utils.appdirs.__version__ = '1.4.4'
- riptable.Utils.appdirs.__version_info__
- riptable.Utils.appdirs._get_win_folder
- riptable.Utils.appdirs.appname = 'MyApp'
- riptable.Utils.appdirs.os_name
- riptable.Utils.appdirs.unicode