diff options
author | Alistair Bush <ali_bush@gentoo.org> | 2008-01-03 03:16:41 +0000 |
---|---|---|
committer | Alistair Bush <ali_bush@gentoo.org> | 2008-01-03 03:16:41 +0000 |
commit | d4b391a81dbb5bb0866ae338631236718b982adf (patch) | |
tree | 187e924c6ac6e27cc7dc0ae966dc9c9033597f9e /src/py/javatoolkit/parser/manifest.py | |
parent | Refactored code of active sub-projects into new file structure. Currently mis... (diff) | |
download | javatoolkit-d4b391a81dbb5bb0866ae338631236718b982adf.tar.gz javatoolkit-d4b391a81dbb5bb0866ae338631236718b982adf.tar.bz2 javatoolkit-d4b391a81dbb5bb0866ae338631236718b982adf.zip |
Started setup.py and migrated more tools.
svn path=/projects/javatoolkit/branches/layout_refactor_branch/; revision=5884
Diffstat (limited to 'src/py/javatoolkit/parser/manifest.py')
-rw-r--r-- | src/py/javatoolkit/parser/manifest.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/py/javatoolkit/parser/manifest.py b/src/py/javatoolkit/parser/manifest.py new file mode 100644 index 0000000..810914a --- /dev/null +++ b/src/py/javatoolkit/parser/manifest.py @@ -0,0 +1,61 @@ +#! /usr/bin/python +# +# Copyright(c) 2006, James Le Cuirot <chewi@aura-online.co.uk> +# +# Licensed under the GNU General Public License, v2 +# +# $Header: $ + +from tree import * +import parser + +class ManifestParser(parser.Parser): + + def parse(self, ins): + """ Parse an input stream containing a MANIFEST.MF file. Return a + structured document represented by tree.Node + + @param ins - input stream + @return tree.Node containing the structured representation + """ + + lineno = 0 + attrib = "" + value = "" + root = Node() + + for x in ins.readlines(): + lineno += 1 + + if len(x.strip()) == 0: + continue + + if x[:1] == " ": + if attrib == "": + raise ParseError("Malformed line " + str(lineno)) + + value += x.strip() + continue + + xs = x.split(": ", 2) + + if len(xs) > 1: + if attrib != "": + root.add_kid(Node(attrib,value)) + + attrib = xs[0] + value = xs[1].strip() + + else: + raise ParseError("Malformed line " + str(lineno)) + + if attrib != "": + root.add_kid(Node(attrib,value)) + + return root + + def output(self, tree): + tree.output("", ": ", "", ",", " "); + +if __name__ == "__main__": + print "This is not an executable module" |