diff options
author | Robert Buchholz <rbu@goodpoint.de> | 2009-09-25 03:08:57 +0200 |
---|---|---|
committer | Robert Buchholz <rbu@goodpoint.de> | 2009-09-25 03:08:57 +0200 |
commit | ec0bd9c754e39480bfbee8956318226ffe541549 (patch) | |
tree | 710c09beda554513de2e1cfb0918612c39f3f81c | |
parent | Tidy up and add planning for repo config (diff) | |
download | repositories-xml-format-ec0bd9c754e39480bfbee8956318226ffe541549.tar.gz repositories-xml-format-ec0bd9c754e39480bfbee8956318226ffe541549.tar.bz2 repositories-xml-format-ec0bd9c754e39480bfbee8956318226ffe541549.zip |
Add simple layman parser and tidy.config
-rwxr-xr-x | layman-parser.py | 42 | ||||
-rw-r--r-- | tidy.config | 9 |
2 files changed, 51 insertions, 0 deletions
diff --git a/layman-parser.py b/layman-parser.py new file mode 100755 index 0000000..d20b20a --- /dev/null +++ b/layman-parser.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +import xml.etree.ElementTree as ET + +def indent(elem, level=0): + i = "\n" + level*" " + if len(elem): + if not elem.text or not elem.text.strip(): + elem.text = i + " " + if not elem.tail or not elem.tail.strip(): + elem.tail = i + for elem in elem: + indent(elem, level+1) + if not elem.tail or not elem.tail.strip(): + elem.tail = i + else: + if level and (not elem.tail or not elem.tail.strip()): + elem.tail = i + +def comp_elems (a, b): + return cmp(a.get('name'), b.get('name')) + +a = ET.parse(open('layman-global.txt')) + +x = a.getroot() + +x.getchildren().sort(cmp=comp_elems) + +#for c in x.getchildren(): +# f = ET.SubElement(c, 'feed') +# f.text = c.get('src') + +indent(x) +a.write('file') + +C = [t.get('name') for t in x.getchildren()] +for n in set(C): + C.remove(n) + +print 'dupes:' + str(C) + + diff --git a/tidy.config b/tidy.config new file mode 100644 index 0000000..9b7d7ec --- /dev/null +++ b/tidy.config @@ -0,0 +1,9 @@ +indent: auto +indent-spaces: 2 +indent-attributes: yes +punctuation-wrap: yes +sort-attributes: alpha +vertical-space: yes +wrap-attributes: yes +wrap: 80 +force-output: yes |