diff options
author | 2009-10-05 06:15:28 +0200 | |
---|---|---|
committer | 2009-10-05 06:15:28 +0200 | |
commit | b7d260531315ac5f2f3a390fbe9b9031a513b61e (patch) | |
tree | c459d832ef7bd2fdc93066ef3a8d68182e322ff5 /write-overlays-ini.py | |
parent | Add post-update Git hook sample (diff) | |
download | repositories-xml-format-b7d260531315ac5f2f3a390fbe9b9031a513b61e.tar.gz repositories-xml-format-b7d260531315ac5f2f3a390fbe9b9031a513b61e.tar.bz2 repositories-xml-format-b7d260531315ac5f2f3a390fbe9b9031a513b61e.zip |
Add script to auto-update planet config
Diffstat (limited to 'write-overlays-ini.py')
-rwxr-xr-x | write-overlays-ini.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/write-overlays-ini.py b/write-overlays-ini.py new file mode 100755 index 0000000..d47e88a --- /dev/null +++ b/write-overlays-ini.py @@ -0,0 +1,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() |