diff options
author | Sebastian Pipping <sebastian@pipping.org> | 2009-09-26 04:59:55 +0200 |
---|---|---|
committer | Sebastian Pipping <sebastian@pipping.org> | 2009-09-26 04:59:55 +0200 |
commit | 14f4047d2a9614485db6b37dd69c47faceeda0f8 (patch) | |
tree | ed02674b40c410c29a51883b277a4c5b65717ba3 | |
parent | Add repositories.xml 1.0 grammars (diff) | |
download | repositories-xml-format-14f4047d2a9614485db6b37dd69c47faceeda0f8.tar.gz repositories-xml-format-14f4047d2a9614485db6b37dd69c47faceeda0f8.tar.bz2 repositories-xml-format-14f4047d2a9614485db6b37dd69c47faceeda0f8.zip |
Allow passing extra data to the translator
-rw-r--r-- | extradata.py | 75 | ||||
-rwxr-xr-x | layman-parser.py | 44 |
2 files changed, 104 insertions, 15 deletions
diff --git a/extradata.py b/extradata.py new file mode 100644 index 0000000..b3bdc22 --- /dev/null +++ b/extradata.py @@ -0,0 +1,75 @@ +QUALITY_CORE = 'core' +QUALITY_STABLE = 'stable' +QUALITY_TESTING = 'testing' +QUALITY_EXPERIMENTAL = 'experimental' +QUALITY_GRAVEYARD = 'graveyard' + +TRANSITION_DATA_EXTRA = { + 'bazaar':{ + 'maintainer':{ + 'name':'Mark Lee', + 'email':'malept@malept.com', + }, + }, + 'lila-theme':{ + 'maintainer':{ + 'email':'fosstux@gmail.com', + }, + }, + 'rbu':{ + 'quality':QUALITY_EXPERIMENTAL, + 'maintainer':{ + 'name':'Robert Buchholz', + }, + }, + 'sping':{ + 'quality':QUALITY_EXPERIMENTAL, + 'maintainer':{ + 'name':'Sebastian Pipping', + }, + 'feeds':[ + 'http://git.goodpoint.de/?p=overlay-sping.git;a=atom', + 'http://git.goodpoint.de/?p=overlay-sping.git;a=rss', + ], + }, +} + +# List more or less from current <http://overlays.gentoo.org/> +TRANSITION_DATA_PROJECTS = set(( + 'cell', + 'efika', + 'emacs', + 'finnish', + 'gnome', + 'gnustep', + 'hardened-development', + 'java-overlay', + 'kde-testing', + 'kolab', + 'mozilla', + 'mysql-testing', + 'nx', + 'perl-experimental', + 'php-4', + 'php-experimental', + 'php-testing', + 'postgresql-experimental', + 'postgresql-testing', + 'powerpc', + 'python', + 'rox', + 'ruby', + 'science', + 'sunrise', + 'toolchain', + 'vdr-devel', + 'vdr-experimental', + 'vdr-testing', + 'vdr-xine', + 'vmware', + 'voip', + 'vps', + 'webapps-experimental', + 'xen', + 'xfce-dev', +)) diff --git a/layman-parser.py b/layman-parser.py index 5a9d295..dee43b2 100755 --- a/layman-parser.py +++ b/layman-parser.py @@ -3,6 +3,8 @@ import xml.etree.ElementTree as ET import codecs +from extradata import * # local + def to_ascii(o, current_encoding='utf-8'): if not isinstance(o, basestring): return o @@ -30,6 +32,9 @@ a = ET.parse(open('layman-global.txt')) overlays = a.getroot() for overlay in overlays: + repo_name = overlay.attrib['name'] + extra_data = TRANSITION_DATA_EXTRA.get(repo_name, {}) + # Transform 'overlay' tag overlay.tag = 'repo' @@ -47,7 +52,8 @@ for overlay in overlays: maintainer = ET.Element('maintainer') overlay.append(maintainer) email = ET.Element('email') - email.text = overlay.attrib['contact'] + email.text = extra_data.get('maintainer', {}).\ + get('email', overlay.attrib['contact']) del overlay.attrib['contact'] maintainer.append(email) @@ -60,25 +66,33 @@ for overlay in overlays: overlay.append(source) # Extend by quality label - overlay.attrib['quality'] = 'experimental' # TODO + try: + overlay.attrib['quality'] = extra_data['quality'] + except KeyError: + pass # Extend by maintainer project flag - maintainer.attrib['project'] = 'no' # TODO + if repo_name in TRANSITION_DATA_PROJECTS: + maintainer.attrib['project'] = 'yes' # Extend by maintainer name - name = ET.Element('name') - name.text = 'TODO' # TODO - maintainer.append(name) - - # Extend by feed URI - feed = ET.Element('feed') - overlay.append(feed) - feed.text = 'http://www.example.org/TODO/' # TODO + try: + maint_name = extra_data['maintainer']['name'] + name = ET.Element('name') + name.text = maint_name + maintainer.append(name) + except KeyError: + pass - # Fix issues on the fly - if email.text.find('@') == -1 or \ - email.text.find(' ') != -1: - email.text = 'todo@example.org' # TODO + # Extend by feed URIs + try: + feed_uris = extra_data['feeds'] + except KeyError: + feed_uris = () + for uri in feed_uris: + feed = ET.Element('feed') + feed.text = uri + overlay.append(feed) # Transform 'overlays' tag overlays.tag = 'repositories' |