aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Bush <ali_bush@gentoo.org>2008-01-05 22:52:06 +0000
committerAlistair Bush <ali_bush@gentoo.org>2008-01-05 22:52:06 +0000
commitba017b6637ce09e56d89196b90c4bc4c14ab4a5e (patch)
tree8a682070345d9c8160dc8d117bae8cd4762f2fbd
parentMoving old projects into obsolete directory. Will delete before merge. (diff)
downloadjavatoolkit-ba017b6637ce09e56d89196b90c4bc4c14ab4a5e.tar.gz
javatoolkit-ba017b6637ce09e56d89196b90c4bc4c14ab4a5e.tar.bz2
javatoolkit-ba017b6637ce09e56d89196b90c4bc4c14ab4a5e.zip
Modified headers and added vim modeline.
svn path=/projects/javatoolkit/branches/layout_refactor_branch/; revision=5892
-rw-r--r--src/py/buildparser2
-rwxr-xr-xsrc/py/class-version-verify.py2
-rw-r--r--src/py/javatoolkit/__init__.py2
-rw-r--r--src/py/javatoolkit/classpath.py80
-rw-r--r--src/py/javatoolkit/cvv.py2
-rw-r--r--src/py/javatoolkit/maven/MavenPom.py2
-rw-r--r--src/py/javatoolkit/output.py17
-rw-r--r--src/py/javatoolkit/parser/buildproperties.py103
-rw-r--r--src/py/javatoolkit/parser/helpers.py84
-rw-r--r--src/py/javatoolkit/parser/manifest.py69
-rw-r--r--src/py/javatoolkit/parser/parser.py13
-rw-r--r--src/py/javatoolkit/parser/tree.py175
-rw-r--r--src/py/javatoolkit/xml/DomRewriter.py3
-rw-r--r--src/py/javatoolkit/xml/SaxRewriter.py2
14 files changed, 267 insertions, 289 deletions
diff --git a/src/py/buildparser b/src/py/buildparser
index 0cff6d3..62a2a83 100644
--- a/src/py/buildparser
+++ b/src/py/buildparser
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python
#
# Copyright(c) 2006, James Le Cuirot <chewi@aura-online.co.uk>
# Copyright(c) 2005, Karl Trygve Kalleberg <karltk@gentoo.org>
diff --git a/src/py/class-version-verify.py b/src/py/class-version-verify.py
index 4d28e42..dbfb7d5 100755
--- a/src/py/class-version-verify.py
+++ b/src/py/class-version-verify.py
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/usr/bin/env python
#
# Copyright(c) 2005, Thomas Matthijs <axxo@gentoo.org>
# Copyright(c) 2005, Gentoo Foundation
diff --git a/src/py/javatoolkit/__init__.py b/src/py/javatoolkit/__init__.py
index 89a74a8..5d9dcee 100644
--- a/src/py/javatoolkit/__init__.py
+++ b/src/py/javatoolkit/__init__.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python2
+#!/usr/bin/env python
#
# Copyright(c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright(c) 2004, Gentoo Foundation
diff --git a/src/py/javatoolkit/classpath.py b/src/py/javatoolkit/classpath.py
index c570774..18c6857 100644
--- a/src/py/javatoolkit/classpath.py
+++ b/src/py/javatoolkit/classpath.py
@@ -1,5 +1,3 @@
-#! /usr/bin/python2
-#
# Copyright(c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright(c) 2004, Gentoo Foundation
#
@@ -8,65 +6,63 @@
# $Header: /var/cvsroot/gentoo-src/javatoolkit/src/javatoolkit/classpath.py,v 1.4 2004/11/08 20:06:06 karltk Exp $
class ClasspathIter:
- """An iterator for the Classpath class, below."""
+ """An iterator for the Classpath class, below."""
- def __init__(self, classpath):
- self._classpath = classpath
- self._index = 0
+ def __init__(self, classpath):
+ self._classpath = classpath
+ self._index = 0
- def next(self):
- self._index += 1
- if self._index >= len(self._classpath.classpath):
- raise StopIteration
- return self._classpath.classpath[self._index]
+ def next(self):
+ self._index += 1
+ if self._index >= len(self._classpath.classpath):
+ raise StopIteration
+ return self._classpath.classpath[self._index]
class Classpath:
- """A classpath object provides a collection interface to the elements of a : separated path list. """
-
- def __init__(self, classpath_string = None):
- if classpath_string != None:
- cs = classpath_string.strip().strip("\"")
- self.classpath = cs.split(":")
- else:
- self.classpath = []
-
-
- def __iter__(self):
- """Returns iterator. Elements of the original classpath string are considered split by ':'."""
+ """A classpath object provides a collection interface to the elements of a : separated path list. """
+
+ def __init__(self, classpath_string = None):
+ if classpath_string != None:
+ cs = classpath_string.strip().strip("\"")
+ self.classpath = cs.split(":")
+ else:
+ self.classpath = []
+
+
+ def __iter__(self):
+ """Returns iterator. Elements of the original classpath string are considered split by ':'."""
- return ClasspathIter(self)
+ return ClasspathIter(self)
- def __len__(self):
- """Returns length (number of elements) in this classpath."""
+ def __len__(self):
+ """Returns length (number of elements) in this classpath."""
- return len(self.classpath)
+ return len(self.classpath)
- def __getitem__(self, i):
- """Returns i'th element."""
+ def __getitem__(self, i):
+ """Returns i'th element."""
- return self.classpath[i]
+ return self.classpath[i]
- def __setitem__(self, i, val):
- """Sets i'th element."""
+ def __setitem__(self, i, val):
+ """Sets i'th element."""
- self.classpath[i] = val
+ self.classpath[i] = val
- def __str__(self):
- """Constructs a suitable string representation of the classpath."""
+ def __str__(self):
+ """Constructs a suitable string representation of the classpath."""
- return ":".join(self.classpath)
+ return ":".join(self.classpath)
- def append(self, element):
- """Appends an path to the classpath."""
+ def append(self, element):
+ """Appends an path to the classpath."""
- self.classpath.append(element)
+ self.classpath.append(element)
-
-if __name__ == "__main__":
- print "This is not an exectuable module" \ No newline at end of file
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/cvv.py b/src/py/javatoolkit/cvv.py
index de4e21b..72375d3 100644
--- a/src/py/javatoolkit/cvv.py
+++ b/src/py/javatoolkit/cvv.py
@@ -49,4 +49,4 @@ class cvv:
if filename.endswith(".jar"):
self.do_jar(filename)
-#set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/maven/MavenPom.py b/src/py/javatoolkit/maven/MavenPom.py
index 8ad8cca..8a7fcd9 100644
--- a/src/py/javatoolkit/maven/MavenPom.py
+++ b/src/py/javatoolkit/maven/MavenPom.py
@@ -208,3 +208,5 @@ class MavenPom:
if callback:
callback(self.mydoc,**kwargs)
+
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/output.py b/src/py/javatoolkit/output.py
index 05192ef..6f7680d 100644
--- a/src/py/javatoolkit/output.py
+++ b/src/py/javatoolkit/output.py
@@ -1,5 +1,3 @@
-#! /usr/bin/python2
-#
# Copyright(c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright(c) 2004, Gentoo Foundation
#
@@ -12,17 +10,16 @@ import sys
# FIXME: Use gentoolkit stuff instead
def eerror(s):
- sys.stderr.write("!!! " + s + "\n")
+ sys.stderr.write("!!! " + s + "\n")
def ewarn(s):
- sys.stdout.write("* " + s + "\n")
+ sys.stdout.write("* " + s + "\n")
def einfo(s):
- sys.stdout.write("* " + s + "\n")
+ sys.stdout.write("* " + s + "\n")
def die(err, s):
- eerror(s)
- sys.exit(err)
-
-if __name__ == "__main__":
- print "This is not an executable module" \ No newline at end of file
+ eerror(s)
+ sys.exit(err)
+
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/parser/buildproperties.py b/src/py/javatoolkit/parser/buildproperties.py
index 0c2ee53..468903c 100644
--- a/src/py/javatoolkit/parser/buildproperties.py
+++ b/src/py/javatoolkit/parser/buildproperties.py
@@ -1,5 +1,3 @@
-#! /usr/bin/python
-#
# Copyright(c) 2006, James Le Cuirot <chewi@aura-online.co.uk>
# Copyright(c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright(c) 2004, Gentoo Foundation
@@ -13,71 +11,70 @@ import parser
class BuildPropertiesParser(parser.Parser):
- def parse(self, ins):
- """ Parse an input stream containing an ant build.properties file. Return a
- structured document represented by tree.Node
+ def parse(self, ins):
+ """ Parse an input stream containing an ant build.properties file. Return a
+ structured document represented by tree.Node
- @param ins - input stream
- @return tree.Node containing the structured representation
- """
+ @param ins - input stream
+ @return tree.Node containing the structured representation
+ """
- lineno = 0
- continued_line = False
- inside_html_comment = False
- attrib = ""
- value = ""
- root = Node()
+ lineno = 0
+ continued_line = False
+ inside_html_comment = False
+ attrib = ""
+ value = ""
+ root = Node()
- for x in ins.readlines():
- lineno += 1
- x = x.strip()
+ for x in ins.readlines():
+ lineno += 1
+ x = x.strip()
- if inside_html_comment and x.find("-->") != -1:
- inside_html_comment = False
- x = x.split("-->", 1)[0]
+ if inside_html_comment and x.find("-->") != -1:
+ inside_html_comment = False
+ x = x.split("-->", 1)[0]
- if x.find("<!--") != -1:
- inside_html_comment = True
+ if x.find("<!--") != -1:
+ inside_html_comment = True
- if inside_html_comment:
- continue
+ if inside_html_comment:
+ continue
- if continued_line:
- continued_line = False
- value += x.strip("\"")
+ if continued_line:
+ continued_line = False
+ value += x.strip("\"")
- if len(value) and value[-1] == "\\":
- value = value[:-1]
- continued_line = True
- continue
+ if len(value) and value[-1] == "\\":
+ value = value[:-1]
+ continued_line = True
+ continue
- root.add_kid(Node(attrib,value))
- continue
+ root.add_kid(Node(attrib,value))
+ continue
- if len(x) == 0 or x[:1] == "#":
- continue
+ if len(x) == 0 or x[:1] == "#":
+ continue
- x = x.split("#", 1)[0]
- xs = x.split("=", 2)
+ x = x.split("#", 1)[0]
+ xs = x.split("=", 2)
- if len(xs) > 1:
- attrib = xs[0].strip()
- value = xs[1].strip().strip("\"")
+ if len(xs) > 1:
+ attrib = xs[0].strip()
+ value = xs[1].strip().strip("\"")
- if value != "" and value[-1] == "\\":
- value = value[:-1]
- continued_line = True
- continue
+ if value != "" and value[-1] == "\\":
+ value = value[:-1]
+ continued_line = True
+ continue
- root.add_kid(Node(attrib,value))
+ root.add_kid(Node(attrib,value))
- else:
- raise ParseError("Malformed line " + str(lineno))
+ else:
+ raise ParseError("Malformed line " + str(lineno))
- return root
-
- def output(self, tree):
- tree.output("", " = ", "")
+ return root
+
+ def output(self, tree):
+ tree.output("", " = ", "")
-if __name__ == "__main__":
- print "This is not an executable module"
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/parser/helpers.py b/src/py/javatoolkit/parser/helpers.py
index 62815de..0f5e77c 100644
--- a/src/py/javatoolkit/parser/helpers.py
+++ b/src/py/javatoolkit/parser/helpers.py
@@ -1,5 +1,3 @@
-#! /usr/bin/python
-#
# Copyright(c) 2006, James Le Cuirot <chewi@aura-online.co.uk>
# Copyright(c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright(c) 2004, Gentoo Foundation
@@ -8,54 +6,52 @@
#
# $Header: $
-
def expand(root, expr, realroot = None):
- """Evaluates a path expression on a given tree.
-
- @param root - the root of the tree
- @param expr - the expression to resolve
-
- @return the expanded string
- """
-
- if realroot == None:
- realroot = root
-
- expanded = ""
- in_varref = False
- varname = ""
+ """Evaluates a path expression on a given tree.
+
+ @param root - the root of the tree
+ @param expr - the expression to resolve
+
+ @return the expanded string
+ """
+
+ if realroot == None:
+ realroot = root
+
+ expanded = ""
+ in_varref = False
+ varname = ""
- for i in range(len(expr)):
- x = expr[i]
+ for i in range(len(expr)):
+ x = expr[i]
- if in_varref:
+ if in_varref:
- if x == "}":
- in_varref = False
- expanded += expand(root, realroot.find_node(varname).value, realroot)
- varname = ""
- elif x != "{":
- varname += expr[i]
+ if x == "}":
+ in_varref = False
+ expanded += expand(root, realroot.find_node(varname).value, realroot)
+ varname = ""
+ elif x != "{":
+ varname += expr[i]
- elif x == "$" and i < len(expr) and expr[i + 1] == "{":
- in_varref = True
+ elif x == "$" and i < len(expr) and expr[i + 1] == "{":
+ in_varref = True
- else:
- expanded += x
+ else:
+ expanded += x
- return expanded
+ return expanded
def strip_varmarker(s):
- """Strips away ${ and } in a variable expression. Idempotent if marker not found.
-
- Example: "${foo}" -> "foo"
- Example: "foo" -> "foo"
- """
-
- if s.startswith("${") and s.endswith("}"):
- return s[2:-1]
-
- return s
-
-if __name__ == "__main__":
- print "This is not an executable module"
+ """Strips away ${ and } in a variable expression. Idempotent if marker not found.
+
+ Example: "${foo}" -> "foo"
+ Example: "foo" -> "foo"
+ """
+
+ if s.startswith("${") and s.endswith("}"):
+ return s[2:-1]
+
+ return s
+
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/parser/manifest.py b/src/py/javatoolkit/parser/manifest.py
index 810914a..c5c3a67 100644
--- a/src/py/javatoolkit/parser/manifest.py
+++ b/src/py/javatoolkit/parser/manifest.py
@@ -1,5 +1,3 @@
-#! /usr/bin/python
-#
# Copyright(c) 2006, James Le Cuirot <chewi@aura-online.co.uk>
#
# Licensed under the GNU General Public License, v2
@@ -11,51 +9,50 @@ 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
+ 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
- """
+ @param ins - input stream
+ @return tree.Node containing the structured representation
+ """
- lineno = 0
- attrib = ""
- value = ""
- root = Node()
+ lineno = 0
+ attrib = ""
+ value = ""
+ root = Node()
- for x in ins.readlines():
- lineno += 1
+ for x in ins.readlines():
+ lineno += 1
- if len(x.strip()) == 0:
- continue
+ if len(x.strip()) == 0:
+ continue
- if x[:1] == " ":
- if attrib == "":
- raise ParseError("Malformed line " + str(lineno))
+ if x[:1] == " ":
+ if attrib == "":
+ raise ParseError("Malformed line " + str(lineno))
- value += x.strip()
- continue
+ value += x.strip()
+ continue
- xs = x.split(": ", 2)
+ xs = x.split(": ", 2)
- if len(xs) > 1:
- if attrib != "":
- root.add_kid(Node(attrib,value))
+ if len(xs) > 1:
+ if attrib != "":
+ root.add_kid(Node(attrib,value))
- attrib = xs[0]
- value = xs[1].strip()
+ attrib = xs[0]
+ value = xs[1].strip()
- else:
- raise ParseError("Malformed line " + str(lineno))
+ else:
+ raise ParseError("Malformed line " + str(lineno))
- if attrib != "":
- root.add_kid(Node(attrib,value))
+ if attrib != "":
+ root.add_kid(Node(attrib,value))
- return root
+ return root
- def output(self, tree):
- tree.output("", ": ", "", ",", " ");
+ def output(self, tree):
+ tree.output("", ": ", "", ",", " ");
-if __name__ == "__main__":
- print "This is not an executable module"
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/parser/parser.py b/src/py/javatoolkit/parser/parser.py
index e99a7a1..55e57f3 100644
--- a/src/py/javatoolkit/parser/parser.py
+++ b/src/py/javatoolkit/parser/parser.py
@@ -1,5 +1,3 @@
-#! /usr/bin/python
-#
# Copyright(c) 2006, James Le Cuirot <chewi@aura-online.co.uk>
#
# Licensed under the GNU General Public License, v2
@@ -7,10 +5,9 @@
# $Header: $
class Parser:
- def parse(self, ins):
- raise NotImplementedError
- def output(self, tree):
- raise NotImplementedError
+ def parse(self, ins):
+ raise NotImplementedError
+ def output(self, tree):
+ raise NotImplementedError
-if __name__ == "__main__":
- print "This is not an executable module"
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/parser/tree.py b/src/py/javatoolkit/parser/tree.py
index eb51874..f5987b5 100644
--- a/src/py/javatoolkit/parser/tree.py
+++ b/src/py/javatoolkit/parser/tree.py
@@ -1,5 +1,3 @@
-#! /usr/bin/python
-#
# Copyright(c) 2006, James Le Cuirot <chewi@aura-online.co.uk>
# Copyright(c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright(c) 2004, Gentoo Foundation
@@ -11,97 +9,96 @@
import sys
class ParseError:
- def __init__(self, error):
- self.error = error
+ def __init__(self, error):
+ self.error = error
class NodeIter:
- def __init__(self, node):
- self._node = node
- self._index = 0
- def next(self):
- self._index += 1
- if self._index >= len(self._node._kids):
- raise StopIteration
- return self._node._kids[self._index]
+ def __init__(self, node):
+ self._node = node
+ self._index = 0
+ def next(self):
+ self._index += 1
+ if self._index >= len(self._node._kids):
+ raise StopIteration
+ return self._node._kids[self._index]
class Node:
- def __init__(self, name = None, value = None):
- self.name = name
- self.value = value
- self._kids = []
-
- def __iter__(self):
- return NodeIter(self)
-
- def add_kid(self, kid):
- for x in self._kids:
- if x.name == kid.name:
- return
-
- self._kids.append(kid)
-
- def _dump_kids(self, indent, ous):
- for x in self._kids:
- x.dump(indent + 1)
-
- """
- Dump self as text to stream.
- """
- def dump(self, indent = 0, ous = sys.stdout):
- if self.name:
- ous.write((" " * indent) + self.name + " = " + self.value + "\n")
-
- self._dump_kids(indent, ous)
-
- """
- Output self as text to stream using the given format.
- """
- def output(self, before, between, after, wrap = None, indent = "", ous = sys.stdout):
- if self.name:
- outval = self.value
-
- if wrap != None:
- outval = outval.replace(wrap, wrap + "\n" + indent)
-
- ous.write(before + self.name + between + outval + after + "\n")
-
- for x in self._kids:
- x.output(before, between, after, wrap, indent, ous)
+ def __init__(self, name = None, value = None):
+ self.name = name
+ self.value = value
+ self._kids = []
+
+ def __iter__(self):
+ return NodeIter(self)
+
+ def add_kid(self, kid):
+ for x in self._kids:
+ if x.name == kid.name:
+ return
+
+ self._kids.append(kid)
+
+ def _dump_kids(self, indent, ous):
+ for x in self._kids:
+ x.dump(indent + 1)
+
+ """
+ Dump self as text to stream.
+ """
+ def dump(self, indent = 0, ous = sys.stdout):
+ if self.name:
+ ous.write((" " * indent) + self.name + " = " + self.value + "\n")
+
+ self._dump_kids(indent, ous)
+
+ """
+ Output self as text to stream using the given format.
+ """
+ def output(self, before, between, after, wrap = None, indent = "", ous = sys.stdout):
+ if self.name:
+ outval = self.value
+
+ if wrap != None:
+ outval = outval.replace(wrap, wrap + "\n" + indent)
+
+ ous.write(before + self.name + between + outval + after + "\n")
+
+ for x in self._kids:
+ x.output(before, between, after, wrap, indent, ous)
- """
- Returns a lists of all the node names.
- """
- def node_names(self):
- names = []
-
- if self.name:
- names.append(self.name)
-
- for x in self._kids:
- names.extend(x.node_names())
-
- return names
+ """
+ Returns a lists of all the node names.
+ """
+ def node_names(self):
+ names = []
+
+ if self.name:
+ names.append(self.name)
+
+ for x in self._kids:
+ names.extend(x.node_names())
+
+ return names
- """
- Find a given node name in a tree.
-
- @param tree - the tree to search in
- @param nodename - the name of the node to search for
-
- @return reference to the found node, if any
- """
- def find_node(self, nodename):
- if self.name == nodename:
- return self
+ """
+ Find a given node name in a tree.
+
+ @param tree - the tree to search in
+ @param nodename - the name of the node to search for
+
+ @return reference to the found node, if any
+ """
+ def find_node(self, nodename):
+ if self.name == nodename:
+ return self
+
+ else:
+ for x in self._kids:
+ y = x.find_node(nodename)
+
+ if y != None:
+ return y
+
+ return None
- else:
- for x in self._kids:
- y = x.find_node(nodename)
-
- if y != None:
- return y
-
- return None
-
-if __name__ == "__main__":
- print "This is not an executable module"
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/xml/DomRewriter.py b/src/py/javatoolkit/xml/DomRewriter.py
index f5daf9f..92844b9 100644
--- a/src/py/javatoolkit/xml/DomRewriter.py
+++ b/src/py/javatoolkit/xml/DomRewriter.py
@@ -117,5 +117,4 @@ class DomRewriter:
from xml.dom.ext import PrettyPrint
PrettyPrint(self.document,stream)
-
-#set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
diff --git a/src/py/javatoolkit/xml/SaxRewriter.py b/src/py/javatoolkit/xml/SaxRewriter.py
index bb25e45..0bf9fc6 100644
--- a/src/py/javatoolkit/xml/SaxRewriter.py
+++ b/src/py/javatoolkit/xml/SaxRewriter.py
@@ -129,4 +129,4 @@ class SaxRewriter(XMLGenerator):
parseString(in_stream, self)
self.p(u'\n')
-#set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
+# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap: