blob: d47e88a53c6ac2d059ebf2f20c30b51c93c6ad7d (
plain)
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
49
50
51
52
53
54
55
56
|
#!/usr/bin/env python
# Copyright (C) 2009 Sebastian Pipping <sebastian@pipping.org>
# Licensed under GPL 2 or later
import sys
import os
if len(sys.argv) != 1 + 3:
print "USAGE:\n python %s foo/repositories.xml bar/overlays.base baz/overlays.ini" % \
os.path.basename(sys.argv[0])
sys.exit(1)
repositories_xml_location = sys.argv[1]
overlays_base_location = sys.argv[2]
overlays_ini_location = sys.argv[3]
import xml.etree.ElementTree as ET
from ConfigParser import ConfigParser, DuplicateSectionError
from sharedutils import * # local
a = ET.parse(open(repositories_xml_location))
repositories = a.getroot()
overlays_ini = ConfigParser()
overlays_ini.read(overlays_base_location)
for repo in repositories:
try:
_feed_uri = repo.find('feed').text.strip()
except AttributeError:
continue
try:
overlays_ini.add_section(_feed_uri)
except DuplicateSectionError:
print 'Warning: Feed URI collision on <%s>' % _feed_uri
repo_name = repo.find('name').text.strip()
overlays_ini.set(_feed_uri, 'name', repo_name)
# _official = (repo.attrib.get('type', 'unofficial') == 'official') and 'yes' or 'no'
_owner_type = repo.find('owner').attrib.get('type', 'project')
if _owner_type == 'person':
overlays_ini.set(_feed_uri, 'developer', 'yes')
else: # TODO elif _owner_type == 'project':
overlays_ini.set(_feed_uri, 'project', 'yes')
try:
overlays_ini.set(_feed_uri, 'link', repo.find('homepage').text.strip())
except AttributeError:
print 'Warning: %s is missing a homepage' % repo_name
f = open(overlays_ini_location, 'w')
f.write('# NOTE: This file is generated, do not edit directly.\n\n')
overlays_ini.write(f)
f.close()
|