Skip to content

Commit

Permalink
Merge pull request #42 from dstufft/allow-disabled-appauthor-on-windows
Browse files Browse the repository at this point in the history
Allow disabling the AppAuthor directory on Windows.
  • Loading branch information
Sridhar Ratnakumar committed May 3, 2014
2 parents 44068e3 + 2b4a4a7 commit a2c0f8f
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions appdirs.py
Expand Up @@ -31,9 +31,10 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only required and used on Windows) is the name of the
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname.
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is 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
Expand Down Expand Up @@ -63,7 +64,10 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA"
path = os.path.normpath(_get_win_folder(const))
if appname:
path = os.path.join(path, appauthor, appname)
if appauthor is not False:
path = os.path.join(path, appauthor, appname)
else:
path = os.path.join(path, appname)
elif sys.platform == 'darwin':
path = os.path.expanduser('~/Library/Application Support/')
if appname:
Expand All @@ -82,9 +86,10 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only required and used on Windows) is the name of the
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname.
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is 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
Expand Down Expand Up @@ -112,7 +117,10 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
appauthor = appname
path = os.path.normpath(_get_win_folder("CSIDL_COMMON_APPDATA"))
if appname:
path = os.path.join(path, appauthor, appname)
if appauthor is not False:
path = os.path.join(path, appauthor, appname)
else:
path = os.path.join(path, appname)
elif sys.platform == 'darwin':
path = os.path.expanduser('/Library/Application Support')
if appname:
Expand Down Expand Up @@ -144,9 +152,10 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only required and used on Windows) is the name of the
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname.
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is 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
Expand Down Expand Up @@ -183,9 +192,10 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False)
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only required and used on Windows) is the name of the
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname.
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is 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
Expand Down Expand Up @@ -233,9 +243,10 @@ def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only required and used on Windows) is the name of the
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname.
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is 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
Expand Down Expand Up @@ -265,7 +276,10 @@ def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
appauthor = appname
path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
if appname:
path = os.path.join(path, appauthor, appname)
if appauthor is not False:
path = os.path.join(path, appauthor, appname)
else:
path = os.path.join(path, appname)
if opinion:
path = os.path.join(path, "Cache")
elif sys.platform == 'darwin':
Expand All @@ -286,9 +300,10 @@ def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only required and used on Windows) is the name of the
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname.
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is 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
Expand Down Expand Up @@ -484,3 +499,8 @@ def _get_win_folder_with_ctypes(csidl_name):
dirs = AppDirs(appname)
for prop in props:
print("%s: %s" % (prop, getattr(dirs, prop)))

print("\n-- app dirs (with disabled 'appauthor')")
dirs = AppDirs(appname, appauthor=False)
for prop in props:
print("%s: %s" % (prop, getattr(dirs, prop)))

0 comments on commit a2c0f8f

Please sign in to comment.