1 """Provides the prefix() function for finding cola resources"""
4 from os
.path
import dirname
9 _modpath
= core
.abspath(__file__
)
10 if os
.path
.join('share', 'git-cola', 'lib') in _modpath
:
11 # this is the release tree
12 # __file__ = '$prefix/share/git-cola/lib/cola/__file__.py'
13 _lib_dir
= dirname(dirname(_modpath
))
14 _prefix
= dirname(dirname(dirname(_lib_dir
)))
16 # this is the source tree
17 # __file__ = '$prefix/cola/__file__.py'
18 _prefix
= dirname(dirname(_modpath
))
22 """Return a path relative to cola's installation prefix"""
23 return os
.path
.join(_prefix
, *args
)
27 """Return a path relative to cola's /usr/share/doc/ directory"""
28 return os
.path
.join(_prefix
, 'share', 'doc', 'git-cola', *args
)
32 """Return the path to the cola html documentation."""
33 # index.html only exists after the install-docs target is run,
34 # so fallback to git-cola.txt.
35 htmldocs
= doc('html', 'index.html')
36 if core
.exists(htmldocs
):
38 return doc('git-cola.txt')
43 webbrowser
.open_new_tab(url
)
46 """Return a path relative to cola's /usr/share/ directory"""
47 return prefix('share', 'git-cola', *args
)
51 """Return the full path to an icon file given a basename."""
52 return 'icons:'+basename
56 """Return the path to the style dir within the cola install tree."""
60 def config_home(*args
):
61 config
= core
.getenv('XDG_CONFIG_HOME',
62 os
.path
.join(core
.expanduser('~'), '.config'))
63 return os
.path
.join(config
, 'git-cola', *args
)