mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
check config for duplicate repo settings
This commit is contained in:
parent
61b26bd712
commit
970ca2eaa9
1 changed files with 15 additions and 6 deletions
21
archreposrv
21
archreposrv
|
@ -12,16 +12,25 @@ enable_pretty_logging(logging.DEBUG)
|
||||||
|
|
||||||
from repomon import repomon
|
from repomon import repomon
|
||||||
|
|
||||||
def main(conffile):
|
def check_and_get_repos(config):
|
||||||
config = configparser.ConfigParser(default_section='multi')
|
|
||||||
config.read(conffile)
|
|
||||||
|
|
||||||
repos = config['multi'].get('repos', 'repository')
|
repos = config['multi'].get('repos', 'repository')
|
||||||
for field in ('name', 'path'):
|
for field in ('name', 'path'):
|
||||||
if config['multi'].get(field, None) is not None:
|
if config['multi'].get(field, None) is not None:
|
||||||
raise ValueError('The config %r cannot have default value.' % field)
|
raise ValueError('config %r cannot have default value.' % field)
|
||||||
|
|
||||||
|
repos = {repo.strip() for repo in repos.split(',')}
|
||||||
|
for field in ('name', 'path'):
|
||||||
|
vals = [config[repo].get(field) for repo in repos]
|
||||||
|
if len(vals) != len(set(vals)):
|
||||||
|
raise ValueError('duplicate %s in different repositories.' % field)
|
||||||
|
|
||||||
|
return repos
|
||||||
|
|
||||||
|
def main(conffile):
|
||||||
|
config = configparser.ConfigParser(default_section='multi')
|
||||||
|
config.read(conffile)
|
||||||
|
repos = check_and_get_repos(config)
|
||||||
|
|
||||||
repos = [repo.strip() for repo in repos.split(',')]
|
|
||||||
notifiers = [repomon(config[repo]) for repo in repos]
|
notifiers = [repomon(config[repo]) for repo in repos]
|
||||||
|
|
||||||
ioloop = IOLoop.instance()
|
ioloop = IOLoop.instance()
|
||||||
|
|
Loading…
Add table
Reference in a new issue