forked from dtmateojr/dtmrepo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdtmrepo-repoconf
executable file
·48 lines (36 loc) · 1.02 KB
/
dtmrepo-repoconf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
import ConfigParser
import sys
def usage():
sys.stderr.write('Usage: %s <config file>\n\n' % sys.argv[0].split('/')[-1])
sys.exit(1)
def read_conf(config):
parser = ConfigParser.SafeConfigParser()
try:
parser.read(config)
except:
sys.stderr.write('Error reading %s.\n' % config)
sys.exit(1)
try:
control_opts = parser.items('control')
except:
sys.stderr.write('Missing [control] section in %s.\n' % config)
sys.exit(1)
try:
repolist = parser.items('repos')
except:
sys.stderr.write('Missing [repos] section in %s.\n' % config)
sys.exit(1)
for opt,val in control_opts:
print '%s=%s' % (opt, val)
opts=[]
vals=[]
for opt,val in repolist:
opts.append(opt)
vals.append(val)
print 'repostore=(%s)' % ' '.join(opts)
print 'reponame=(%s)' % ' '.join(vals)
if __name__ == '__main__':
if len(sys.argv) < 2:
usage()
read_conf(sys.argv[1])