1 """Provides the prefix() function for finding cola resources"""
2 from __future__
import division
, absolute_import
, unicode_literals
6 from os
.path
import dirname
11 _modpath
= core
.abspath(__file__
)
12 if os
.path
.join('share', 'git-cola', 'lib') in _modpath
:
13 # this is the release tree
14 # __file__ = '$prefix/share/git-cola/lib/cola/__file__.py'
15 _lib_dir
= dirname(dirname(_modpath
))
16 _prefix
= dirname(dirname(dirname(_lib_dir
)))
17 elif os
.path
.join('pkgs', 'cola') in _modpath
:
18 # Windows release tree
19 # __file__ = $installdir/pkgs/cola/resources.py
20 _prefix
= dirname(dirname(dirname(_modpath
)))
22 # this is the source tree
23 # __file__ = '$prefix/cola/__file__.py'
24 _prefix
= dirname(dirname(_modpath
))
28 """Return a path relative to cola's installation prefix"""
29 return os
.path
.join(_prefix
, *args
)
33 """Return a path relative to cola's /usr/share/doc/ directory"""
34 return os
.path
.join(_prefix
, 'share', 'doc', 'git-cola', *args
)
38 """Return the path to the cola html documentation."""
39 # html/index.html only exists after the install-docs target is run.
40 # Fallback to the source tree and lastly git-cola.rst.
41 paths_to_try
= (('html', 'index.html'),
42 ('_build', 'html', 'index.html'))
43 for paths
in paths_to_try
:
45 if core
.exists(docdir
):
47 return doc('git-cola.rst')
52 webbrowser
.open_new_tab('file://' + url
)
55 """Return a path relative to cola's /usr/share/ directory"""
56 return prefix('share', 'git-cola', *args
)
60 """Return the full path to an icon file given a basename."""
61 return 'icons:'+basename
65 """Return the path to the style dir within the cola install tree."""
69 def config_home(*args
):
70 config
= core
.getenv('XDG_CONFIG_HOME',
71 os
.path
.join(core
.expanduser('~'), '.config'))
72 return os
.path
.join(config
, 'git-cola', *args
)