views.dag: Factor out constants for drawing edges
[git-cola.git] / bin / git-cola
blob4154c4669e2f0a581ef934d1c916a46bf327289f
1 #!/usr/bin/env python
2 # -*- python-mode -*-
3 """Takes care of starting the main function
4 """
6 __copyright__ = """
7 Copyright (C) 2007, 2008, 2009, 2010,
8 David Aguilar <davvid@gmail.com> and contributors
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License version 2 as
12 published by the Free Software Foundation.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 """
21 import os
22 import sys
24 def cola_init():
25 """Provides access to the cola modules"""
26 # Try to detect where it is run from and set prefix and the search path.
27 # It is assumed that the user installed Cola using the --prefix= option
28 prefix = os.path.dirname(os.path.abspath(__file__))
29 if 'Contents/Resources' not in __file__:
30 prefix = os.path.dirname(prefix)
32 # Look for modules in the source or install trees
33 thirdparty = os.path.join(prefix, 'thirdparty')
34 if os.path.exists(thirdparty):
35 # Source tree: prefer cola's modules but allow system versions of thirdparty
36 sys.path.insert(0, prefix)
37 sys.path.append(thirdparty)
38 else:
39 # Install tree: prefer cola
40 paths_to_try = [os.path.join(prefix, 'share', 'git-cola', 'lib')]
41 sys.path = paths_to_try + sys.path
43 # Setup the path so that git finds us when we run 'git cola'
44 path_entries = os.environ.get('PATH').split(os.pathsep)
45 bindir = os.path.dirname(os.path.abspath(__file__))
46 path_entries.insert(0, bindir)
47 path = os.pathsep.join(path_entries)
48 os.environ['PATH'] = path
49 os.putenv('PATH', path)
52 if __name__ == '__main__':
53 # lights, cameras, action
54 cola_init()
55 import cola.main
56 cola.main.main()