Reimplemented ACL generation to avoid quadratic complexity.
[gitosis/httpauth.git] / gitosis / util.py
blob479b2e938ded235efba0cfa80614d6cb402ac963
1 import errno
2 import os
3 from ConfigParser import NoSectionError, NoOptionError
5 def mkdir(*a, **kw):
6 try:
7 os.mkdir(*a, **kw)
8 except OSError, e:
9 if e.errno == errno.EEXIST:
10 pass
11 else:
12 raise
14 def getRepositoryDir(config):
15 repositories = os.path.expanduser('~')
16 try:
17 path = config.get('gitosis', 'repositories')
18 except (NoSectionError, NoOptionError):
19 repositories = os.path.join(repositories, 'repositories')
20 else:
21 repositories = os.path.join(repositories, path)
22 return repositories
24 def getGeneratedFilesDir(config):
25 try:
26 generated = config.get('gitosis', 'generate-files-in')
27 except (NoSectionError, NoOptionError):
28 generated = os.path.expanduser('~/gitosis')
29 return generated
31 def getSSHAuthorizedKeysPath(config):
32 try:
33 path = config.get('gitosis', 'ssh-authorized-keys-path')
34 except (NoSectionError, NoOptionError):
35 path = os.path.expanduser('~/.ssh/authorized_keys')
36 return path