src/mercurialserver/config.py
changeset 216 0122df83ebd0
parent 215 584df0f2e5c7
child 217 32b431977bf9
equal deleted inserted replaced
215:584df0f2e5c7 216:0122df83ebd0
    11     if globalconfig is None:
    11     if globalconfig is None:
    12         globalconfig = ConfigParser.RawConfigParser()
    12         globalconfig = ConfigParser.RawConfigParser()
    13         globalconfig.read(os.path.expanduser("~/.mercurial-server"))
    13         globalconfig.read(os.path.expanduser("~/.mercurial-server"))
    14     return globalconfig
    14     return globalconfig
    15 
    15 
    16 def configExists():
       
    17     try:
       
    18         _getConf()
       
    19         return True
       
    20     except:
       
    21         return False
       
    22 
       
    23 def _getPath(name):
    16 def _getPath(name):
    24     return os.path.expanduser(_getConf().get("paths", name))
    17     return os.path.expanduser(_getConf().get("paths", name))
    25 
    18 
    26 def _getPaths(name): 
    19 def _getPaths(name): 
    27     return [os.path.expanduser(p)
    20     return [os.path.expanduser(p)
    28         for p in _getConf().get("paths", name).split(":")]
    21         for p in _getConf().get("paths", name).split(":")]
    29 
    22 
    30 def getReposPath(): return _getPath("repos")
    23 def getReposPath(): return _getPath("repos")
    31 def getAuthorizedKeysPath(): return _getPath("authorized_keys")
    24 def getAuthorizedKeysPath(): return _getPath("authorized_keys")
       
    25 
       
    26 def configExists():
       
    27     try:
       
    28         _getAuthorizedKeysPath()
       
    29         return True
       
    30     except:
       
    31         return False
    32 
    32 
    33 def getKeysPaths(): return _getPaths("keys")
    33 def getKeysPaths(): return _getPaths("keys")
    34 def getAccessPaths(): return _getPaths("access")
    34 def getAccessPaths(): return _getPaths("access")
    35 
    35 
    36 def getEnv(): return _getConf().items("env")
    36 def getEnv(): return _getConf().items("env")