diff options
author | 2009-09-28 18:36:18 +0200 | |
---|---|---|
committer | 2009-09-28 18:36:18 +0200 | |
commit | ec28915dcf59e7e72747e3032023017a375a350d (patch) | |
tree | a146490533d4794a5adf30c305ad55bf42d5f300 /write-repositories-xml.py | |
parent | Implement repositories.xml to layman-global.txt translator (diff) | |
download | repositories-xml-format-ec28915dcf59e7e72747e3032023017a375a350d.tar.gz repositories-xml-format-ec28915dcf59e7e72747e3032023017a375a350d.tar.bz2 repositories-xml-format-ec28915dcf59e7e72747e3032023017a375a350d.zip |
Convert tabs to 4 spaces (write-repositories-xml.py only)
Diffstat (limited to 'write-repositories-xml.py')
-rwxr-xr-x | write-repositories-xml.py | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/write-repositories-xml.py b/write-repositories-xml.py index 17ddb43..ba770f4 100755 --- a/write-repositories-xml.py +++ b/write-repositories-xml.py @@ -18,79 +18,79 @@ def to_ascii(o, current_encoding='utf-8'): return codecs.encode(s, 'ascii', 'ignore') def append_feed(feed_uri, overlay_object): - feed = ET.Element('feed') - feed.text = feed_uri - overlay_object.append(feed) + feed = ET.Element('feed') + feed.text = feed_uri + overlay_object.append(feed) 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' - - # Transform 'link' tag - link = overlay.find('link') - if link != None: - link.tag = 'homepage' - - # Move 'description' tag - description = overlay.find('description') - overlay.remove(description) - overlay.insert(0, description) - - # Transform 'contact' attribute - owner = ET.Element('owner') - overlay.append(owner) - email = ET.Element('email') - email.text = extra_data.get('owner', {}).\ - get('email', overlay.attrib['contact']) - del overlay.attrib['contact'] - owner.append(email) - - # Transform 'src' and 'type' attribute - source = ET.Element('source') - source.text = overlay.attrib['src'] - del overlay.attrib['src'] - source.attrib['type'] = overlay.attrib['type'] - del overlay.attrib['type'] - overlay.append(source) - - # Extend by quality label - try: - overlay.attrib['quality'] = extra_data['quality'] - except KeyError: - pass - - # Extend by owner type - if repo_name in TRANSITION_DATA_PROJECTS: - owner.attrib['type'] = 'project' - - # Extend by owner name - try: - maint_name = extra_data['owner']['name'] - name = ET.Element('name') - name.text = maint_name - owner.append(name) - except KeyError: - pass - - # Extend by feed URIs - for fe in FEED_EXTRACTORS: - uri = fe['regex'].sub(fe['format'], source.text) - if uri != source.text: - append_feed(uri, overlay) - break - try: - feed_uris = extra_data['feeds'] - except KeyError: - feed_uris = () - for uri in feed_uris: - append_feed(uri, overlay) - + repo_name = overlay.attrib['name'] + extra_data = TRANSITION_DATA_EXTRA.get(repo_name, {}) + + # Transform 'overlay' tag + overlay.tag = 'repo' + + # Transform 'link' tag + link = overlay.find('link') + if link != None: + link.tag = 'homepage' + + # Move 'description' tag + description = overlay.find('description') + overlay.remove(description) + overlay.insert(0, description) + + # Transform 'contact' attribute + owner = ET.Element('owner') + overlay.append(owner) + email = ET.Element('email') + email.text = extra_data.get('owner', {}).\ + get('email', overlay.attrib['contact']) + del overlay.attrib['contact'] + owner.append(email) + + # Transform 'src' and 'type' attribute + source = ET.Element('source') + source.text = overlay.attrib['src'] + del overlay.attrib['src'] + source.attrib['type'] = overlay.attrib['type'] + del overlay.attrib['type'] + overlay.append(source) + + # Extend by quality label + try: + overlay.attrib['quality'] = extra_data['quality'] + except KeyError: + pass + + # Extend by owner type + if repo_name in TRANSITION_DATA_PROJECTS: + owner.attrib['type'] = 'project' + + # Extend by owner name + try: + maint_name = extra_data['owner']['name'] + name = ET.Element('name') + name.text = maint_name + owner.append(name) + except KeyError: + pass + + # Extend by feed URIs + for fe in FEED_EXTRACTORS: + uri = fe['regex'].sub(fe['format'], source.text) + if uri != source.text: + append_feed(uri, overlay) + break + try: + feed_uris = extra_data['feeds'] + except KeyError: + feed_uris = () + for uri in feed_uris: + append_feed(uri, overlay) + # Transform 'overlays' tag overlays.tag = 'repositories' |