diff options
author | 2010-03-06 20:39:40 +0100 | |
---|---|---|
committer | 2010-03-06 20:39:40 +0100 | |
commit | 3b14e177502f3c0d2ac545c7f34ba31f9c956629 (patch) | |
tree | 7158937266c7d31aed4753434e2cb74825a05799 | |
parent | Planet config writer: Filter out unoffical overlays (diff) | |
download | repositories-xml-format-3b14e177502f3c0d2ac545c7f34ba31f9c956629.tar.gz repositories-xml-format-3b14e177502f3c0d2ac545c7f34ba31f9c956629.tar.bz2 repositories-xml-format-3b14e177502f3c0d2ac545c7f34ba31f9c956629.zip |
repsitories.xml converted: Allow overriding input and output location
-rwxr-xr-x | write-repositories-xml.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/write-repositories-xml.py b/write-repositories-xml.py index 02a01bd..61cc7a0 100755 --- a/write-repositories-xml.py +++ b/write-repositories-xml.py @@ -1,7 +1,26 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- # Copyright (C) 2009 Sebastian Pipping <sebastian@pipping.org> # Licensed under GPL 2 or later +import sys +import os +if len(sys.argv) > 1: + layman_global_txt_location = sys.argv[1] +else: + layman_global_txt_location = 'layman-global.txt' + +if len(sys.argv) > 2: + repositories_xml_location = sys.argv[2] +else: + repositories_xml_location = 'repositories.xml' + +if len(sys.argv) > 3: + print "USAGE:\n python %s [foo/layman-global.txt [bar/repositories.xml]]" % \ + os.path.basename(sys.argv[0]) + sys.exit(1) + + import xml.etree.ElementTree as ET import codecs @@ -24,7 +43,7 @@ def append_feed(feed_uri, overlay_object): feed.text = feed_uri overlay_object.append(feed) -a = ET.parse(open('layman-global.txt')) +a = ET.parse(open(layman_global_txt_location)) overlays = a.getroot() for overlay in overlays: @@ -120,7 +139,7 @@ overlays.attrib['version'] = '1.0' recurse_print(overlays) indent(overlays) -repositories_xml = open('repositories.xml', 'w') +repositories_xml = open(repositories_xml_location, 'w') repositories_xml.write("""\ <?xml version="1.0" encoding="UTF-8"?> <!-- $Header$ --> |