summaryrefslogtreecommitdiff
path: root/giscanner/transformer.py
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2015-06-09 21:09:27 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2015-06-20 00:32:19 +0200
commitec91f9d11b40de198b2faf8a80b49dbd71107750 (patch)
treeb1a1c1d14800bac46da2ed3f7994f0426f71453a /giscanner/transformer.py
parent047244537c8ad5725cc3f8e4f9ea0d5e226fe7e0 (diff)
downloadgobject-introspection-ec91f9d11b40de198b2faf8a80b49dbd71107750.tar.gz
scanner: add "XDG Base Directory" functions
Extract cache and data dir lookup code into documented get_user_cache_dir() and get_system_data_dirs() functions. Note that previously, the data dirs code did not fall back to '/usr/local/share:/usr/share' when the XDG_DATA_DIRS environment variable was either not set or empty, as required by the XDG Base Directory Specification. https://bugzilla.gnome.org/show_bug.cgi?id=747770
Diffstat (limited to 'giscanner/transformer.py')
-rw-r--r--giscanner/transformer.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 6ae63897..5f88a617 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -24,6 +24,7 @@ import subprocess
from . import ast
from . import message
+from . import utils
from .cachestore import CacheStore
from .girparser import GIRParser
from .sourcescanner import (
@@ -40,13 +41,6 @@ class TransformerException(Exception):
pass
-_xdg_data_dirs = [x for x in os.environ.get('XDG_DATA_DIRS', '').split(os.pathsep)]
-_xdg_data_dirs.append(DATADIR)
-
-if os.name != 'nt':
- _xdg_data_dirs.append('/usr/share')
-
-
class Transformer(object):
namespace = property(lambda self: self._namespace)
@@ -182,9 +176,17 @@ None."""
# Private
+ def _get_gi_data_dirs(self):
+ data_dirs = utils.get_system_data_dirs()
+ data_dirs.append(DATADIR)
+ if os.name != 'nt':
+ # For backwards compatibility, was always unconditionally added to the list.
+ data_dirs.append('/usr/share')
+ return data_dirs
+
def _find_include(self, include):
searchdirs = self._includepaths[:]
- for path in _xdg_data_dirs:
+ for path in self._get_gi_data_dirs():
searchdirs.append(os.path.join(path, 'gir-1.0'))
searchdirs.append(os.path.join(DATADIR, 'gir-1.0'))