From: Vlastimil Babka Date: Mon, 1 Jan 2007 01:41:29 +0000 (+0000) Subject: Attempt to commit fixed patch that won't get header rewritten. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c3cea7da3158d854c6a31ee78246d275cecca2e9;p=gentoo.git Attempt to commit fixed patch that won't get header rewritten. Package-Manager: portage-2.1.2_rc4-r3 --- diff --git a/dev-java/javatoolkit/Manifest b/dev-java/javatoolkit/Manifest index 28770c5b1fac..955eca2f0fb1 100644 --- a/dev-java/javatoolkit/Manifest +++ b/dev-java/javatoolkit/Manifest @@ -1,6 +1,7 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - +AUX 0.2.0-use-sax-fixed.patch 6145 RMD160 99f755f3f569476c5f6f8032260a3fd06f4917ef SHA1 bdc18ae16d2aac707af49419687693dbf6d0386d SHA256 c836366cce538048fefd8aa8153d9ef9a207006ba41a059df0e2b802094c83a4 +MD5 0c9215836354ab100e1ec9ea8325fdb2 files/0.2.0-use-sax-fixed.patch 6145 +RMD160 99f755f3f569476c5f6f8032260a3fd06f4917ef files/0.2.0-use-sax-fixed.patch 6145 +SHA256 c836366cce538048fefd8aa8153d9ef9a207006ba41a059df0e2b802094c83a4 files/0.2.0-use-sax-fixed.patch 6145 AUX 0.2.0-use-sax.patch 6162 RMD160 b9e3923267ae550ed94f86a21a7d861a0d32aece SHA1 5d5f2d97d12b56df4319c31027bccc88496e86ec SHA256 d65e3d284c018352e1f38de0c6147f218fe55229e2b7ba1aa22d4294639c3d41 MD5 c5c9abad6a545d89fcf4eeec0aa69df2 files/0.2.0-use-sax.patch 6162 RMD160 b9e3923267ae550ed94f86a21a7d861a0d32aece files/0.2.0-use-sax.patch 6162 @@ -47,10 +48,3 @@ SHA256 1027e8adba272e243524ce25c602ae29453a2a80a1e84b2cb9833b8e04f14303 files/di MD5 a7ee385c1073b0497d84ebaa67260098 files/digest-javatoolkit-0.2.0-r1 253 RMD160 be0f9b3066d53e8ef30c85a1266d9adbf9aa60b0 files/digest-javatoolkit-0.2.0-r1 253 SHA256 1027e8adba272e243524ce25c602ae29453a2a80a1e84b2cb9833b8e04f14303 files/digest-javatoolkit-0.2.0-r1 253 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFFmA3icxLzpIGCsLQRAuwNAKCG0Q/JcmL+4JL+0AafkuGlT5kGyACghBNJ -b/lN/DKNEEpy1Zxq0h8ecKA= -=iy8q ------END PGP SIGNATURE----- diff --git a/dev-java/javatoolkit/files/0.2.0-use-sax-fixed.patch b/dev-java/javatoolkit/files/0.2.0-use-sax-fixed.patch new file mode 100644 index 000000000000..08b9cbbcc0bb --- /dev/null +++ b/dev-java/javatoolkit/files/0.2.0-use-sax-fixed.patch @@ -0,0 +1,187 @@ +Index: src/bsfix/xml-rewrite-2.py +=================================================================== +--- src/bsfix/xml-rewrite-2.py (revision 3421) ++++ src/bsfix/xml-rewrite-2.py (working copy) +@@ -3,15 +3,17 @@ + + # Copyright 2004-2006 Gentoo Foundation + # Distributed under the terms of the GNU General Public Licence v2 +-# $Header: /var/cvsroot/gentoo-src/javatoolkit/src/bsfix/xml-rewrite.py,v 1.6 2005/07/19 10:35:18 axxo Exp $ + +-# Author: Saleem Abdulrasool ++# Authors: ++# Saleem Abdulrasool ++# Petteri Räty + # Maintainer: Gentoo Java Herd + # Python based XML modifier + + # ChangeLog + # Petteri Räty + # December 23, 2004 - Initial Write + # December 24, 2004 - Added usage information +@@ -26,6 +28,11 @@ + __version__ = "$Revision: 1.7 $"[11:-2] + + class DomRewriter: ++ """ ++ The old DOM rewriter is still around for index based stuff. It can ++ be used for all the complex stuff but portage needed features should ++ be in StreamRewriterBase subclasses as they are much faster. ++ """ + from xml.dom import NotFoundErr + + def __init__(self, modifyElems, attributes, values=None, index=None): +@@ -61,40 +68,32 @@ + def write(self,stream): + stream.write(self.document.toxml()) + +-class ExpatRewriter: ++class StreamRewriterBase: + + def __init__(self, elems, attributes, values, index): + self.buffer = StringIO.StringIO() +- self.p = self.buffer.write ++ self.__write = self.buffer.write + self.elems = elems + self.attributes = attributes + self.values = values + +- def process(self, in_stream): +- from xml.parsers.expat import ParserCreate +- parser = ParserCreate() ++ def p(self,str): ++ self.__write(str.encode('utf8')) + +- parser.StartElementHandler = self.start_element +- parser.EndElementHandler = self.end_element +- parser.CharacterDataHandler = self.char_data +- parser.ParseFile(in_stream) +- self.p('\n') +- + def write(self, out_stream): +- out_stream.write(self.buffer.getvalue()) +- self.buffer.close() +- self.buffer = StringIO.StringIO() +- self.p = self.buffer.write ++ value = self.buffer.getvalue() ++ out_stream.write(value) ++ self.buffer.truncate(0) + + def write_attr(self,a,v): +- self.buffer.write('%s=%s ' % (a,quoteattr(v))) ++ self.p(u'%s=%s ' % (a,quoteattr(v, {u'©':'©'}))) + + def start_element(self, name, attrs): +- self.p('<%s ' % name) ++ self.p(u'<%s ' % name) + + match = ( name in self.elems ) + +- for a,v in attrs.iteritems(): ++ for a,v in attrs: + if not ( match and a in self.attributes ): + self.write_attr(a,v) + +@@ -102,14 +101,50 @@ + for i, attr in enumerate(self.attributes): + self.write_attr(attr, self.values[i]) + +- self.p('>') ++ self.p(u'>') + ++class ExpatRewriter(StreamRewriterBase): ++ """ ++ The only problem with this Expat based implementation is that it does not ++ handle entities doctypes etc properly so for example dev-java/skinlf fails. ++ """ ++ def process(self, in_stream): ++ from xml.parsers.expat import ParserCreate ++ parser = ParserCreate() ++ ++ parser.StartElementHandler = self.start_element ++ parser.EndElementHandler = self.end_element ++ parser.CharacterDataHandler = self.char_data ++ parser.ParseFile(in_stream) ++ self.p(u'\n') ++ ++ def start_element(self, name, attrs): ++ StreamRewriterBase(self, name, attrs.iteritems()) ++ + def end_element(self,name): +- self.p('' % name) ++ self.p(u'' % name) + + def char_data(self,data): + self.p(escape(data)) + ++from xml.sax.saxutils import XMLGenerator ++class SaxRewriter(XMLGenerator, StreamRewriterBase): ++ """ ++ Using Sax gives us the support for writing back doctypes and all easily ++ and is only marginally slower than expat as it is just a tight layer over it ++ """ ++ def __init__(self, elems, attributes, values, index): ++ StreamRewriterBase.__init__(self, elems, attributes, values, index) ++ XMLGenerator.__init__(self, self.buffer, 'UTF-8') ++ ++ def process(self, in_stream): ++ from xml.sax import parse ++ parse(in_stream, self) ++ self.p(u'\n') ++ ++ def startElement(self, name, attrs): ++ self.start_element(name, attrs.items()) ++ + if __name__ == '__main__': + usage = "XML Rewrite Python Module Version " + __version__ + "\n" + usage += "Copyright 2004 Gentoo Foundation\n" +@@ -166,8 +201,6 @@ + error("You must give value for every attribute you are changing.") + # End Invalid Arguments Check + +- import codecs +- + def get_rewriter(options): + if options.index or options.doDelete: + # java-ant-2.eclass does not use these options so we can optimize the ExpatWriter +@@ -175,23 +208,32 @@ + rewriter = DomRewriter(options.elements, options.attributes, options.values, options.index) + print "Using DOM to rewrite the build.xml files" + else: +- rewriter = ExpatRewriter(options.elements, options.attributes, options.values, options.index) +- print "Using Expat to rewrite the build.xml files" ++ rewriter = SaxRewriter(options.elements, options.attributes, options.values, options.index) ++ print "Using Sax to rewrite the build.xml files" + + return rewriter + + rewriter = get_rewriter(options) + + if options.files: ++ import os + for file in options.files: + print "Rewriting %s" % file +- f = open(file,"r") ++ # First parse the file into memory ++ # Tricks with cwd are needed for relative includes of other xml files to build.xml files ++ cwd = os.getcwd() ++ dirname = os.path.dirname(file) ++ if dirname != '': # for file = build.xml comes out as '' ++ os.chdir(os.path.dirname(file)) ++ f = open(os.path.basename(file),"r") + rewriter.process(f) ++ os.chdir(cwd) + f.close() ++ # Then write it back to the file + f = open(file, "w") +- rewriter.write(codecs.getwriter('utf-8')(f)) ++ rewriter.write(f) + f.close() + else: + rewriter.process(sys.stdin) +- rewriter.write(codecs.getwriter('utf-8')(sys.stdout)) ++ rewriter.write(sys.stdout) +