Skip to content

Commit c97fb7d

Browse files
committed
XDG_DATA_DIRS useage corrected, fixes wrong site_data_dir under Kubuntu
The freedesktop specification states that $XDG_DATA_DIRS is a preference ordered list of where data should be searched (as opposed to 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 #121. This commit changes the default directory in this case to the distribution independent '/usr/local/share'.
1 parent a54ea98 commit c97fb7d

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

appdirs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,20 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
142142
if appname:
143143
path = os.path.join(path, appname)
144144
else:
145-
# XDG default for $XDG_DATA_DIRS
146-
# only first, if multipath is False
147-
path = os.getenv('XDG_DATA_DIRS',
148-
os.pathsep.join(['/usr/local/share', '/usr/share']))
149-
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
145+
# XDG default: $XDG_DATA_DIRS for searching through multiple directories,
146+
# '/usr/local/share' for single application directory
147+
# (for distribution independent files, also '/usr/share' could be used)
148+
if multipath:
149+
path = os.getenv('XDG_DATA_DIRS',
150+
os.pathsep.join(['/usr/local/share', '/usr/share']))
151+
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
152+
else:
153+
pathlist = ['/usr/local/share']
150154
if appname:
151155
if version:
152156
appname = os.path.join(appname, version)
153157
pathlist = [os.sep.join([x, appname]) for x in pathlist]
154-
155-
if multipath:
156-
path = os.pathsep.join(pathlist)
157-
else:
158-
path = pathlist[0]
158+
path = os.pathsep.join(pathlist)
159159
return path
160160

161161
if appname and version:

0 commit comments

Comments
 (0)