equal
deleted
inserted
replaced
18 return globalconfig |
18 return globalconfig |
19 |
19 |
20 def _getPath(name): |
20 def _getPath(name): |
21 return os.path.expanduser(_getConf().get("paths", name)) |
21 return os.path.expanduser(_getConf().get("paths", name)) |
22 |
22 |
23 def _getPaths(name): |
23 def _getPaths(name): |
24 return [os.path.expanduser(p) |
24 return [os.path.expanduser(p) |
25 for p in _getConf().get("paths", name).split(":")] |
25 for p in _getConf().get("paths", name).split(":")] |
26 |
26 |
27 def getReposPath(): return _getPath("repos") |
27 def getReposPath(): return _getPath("repos") |
28 def getAuthorizedKeysPath(): return _getPath("authorized_keys") |
28 def getAuthorizedKeysPath(): return _getPath("authorized_keys") |
38 def getKeysPaths(): return _getPaths("keys") |
38 def getKeysPaths(): return _getPaths("keys") |
39 def getAccessPaths(): return _getPaths("access") |
39 def getAccessPaths(): return _getPaths("access") |
40 |
40 |
41 def getEnv(): return _getConf().items("env") |
41 def getEnv(): return _getConf().items("env") |
42 |
42 |
|
43 def _getdefault(section, option, default, f = lambda x: x): |
|
44 conf = _getConf() |
|
45 if conf.has_option(section, option): |
|
46 return f(conf.get(section, option)) |
|
47 else: |
|
48 return default |
|
49 |
|
50 def getAllowedDots(): |
|
51 return _getdefault("exceptions", "allowdots", [], |
|
52 lambda s: s.split(":")) |
|
53 |
43 # Work out where we are, don't use config. |
54 # Work out where we are, don't use config. |
44 def initExe(): |
55 def initExe(): |
45 global _exePath |
56 global _exePath |
46 _exePath = os.path.dirname(os.path.abspath(sys.argv[0])) |
57 _exePath = os.path.dirname(os.path.abspath(sys.argv[0])) |
47 # Fix $HOME in case of "sudo -u hg refresh-auth" |
58 # Fix $HOME in case of "sudo -u hg refresh-auth" |
48 os.environ['HOME'] = pwd.getpwuid(os.geteuid()).pw_dir |
59 os.environ['HOME'] = pwd.getpwuid(os.geteuid()).pw_dir |
49 |
60 |
50 def getExePath(): |
61 def getExePath(): |
51 return _exePath |
62 return _exePath |
52 |
|