Skip to content

Commit

Permalink
XDG_DATA_DIRS useage corrected, fixes wrong site_data_dir under Kubuntu
Browse files Browse the repository at this point in the history
The freedesktop specification states that XDG_DATA_DIRS is a preference ordered list of where data should be searched (as opposed by where applications should store data). Therefore, for multipath=False, which is used by applications to determine a path to store data, this can lead to unintended paths, as can be seen under issue ActiveState#121. This commit changes the default directory in this case to the distribution independent '/usr/local/share'.
  • Loading branch information
2xB committed Mar 1, 2019
1 parent a54ea98 commit 9cad86a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,20 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
if appname:
path = os.path.join(path, appname)
else:
# XDG default for $XDG_DATA_DIRS
# only first, if multipath is False
path = os.getenv('XDG_DATA_DIRS',
os.pathsep.join(['/usr/local/share', '/usr/share']))
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
# XDG default: $XDG_DATA_DIRS for searching through multiple directories,
# '/usr/local/share' for single application directory
# (for distribution independent files, also '/usr/share' could be used)
if multipath:
path = os.getenv('XDG_DATA_DIRS',
os.pathsep.join(['/usr/local/share', '/usr/share']))
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
else:
pathlist = ['/usr/local/share']
if appname:
if version:
appname = os.path.join(appname, version)
pathlist = [os.sep.join([x, appname]) for x in pathlist]

if multipath:
path = os.pathsep.join(pathlist)
else:
path = pathlist[0]
path = os.pathsep.join(pathlist)
return path

if appname and version:
Expand Down

0 comments on commit 9cad86a

Please sign in to comment.