incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r614011 [3/3] - in /incubator/public/trunk: ./ audit/incubator-2008-01-20.xml audit/incubator-2008-01-20.xml.asc diff.py scanner.py tests.py
Date Mon, 21 Jan 2008 21:14:48 GMT
Added: incubator/public/trunk/audit/incubator-2008-01-20.xml.asc
URL: http://svn.apache.org/viewvc/incubator/public/trunk/audit/incubator-2008-01-20.xml.asc?rev=614011&view=auto
==============================================================================
--- incubator/public/trunk/audit/incubator-2008-01-20.xml.asc (added)
+++ incubator/public/trunk/audit/incubator-2008-01-20.xml.asc Mon Jan 21 13:14:45 2008
@@ -0,0 +1,7 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2.0.7 (GNU/Linux)
+
+iD8DBQBHk7Bpl6Otx30NTe0RAh+HAJ0Vcp5VGLHhJWHXYPlAeRx7+JvoEwCfe4st
+7gSDbdBKPnVTicnM6RkCkr0=
+=cwlA
+-----END PGP SIGNATURE-----

Added: incubator/public/trunk/diff.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/diff.py?rev=614011&view=auto
==============================================================================
--- incubator/public/trunk/diff.py (added)
+++ incubator/public/trunk/diff.py Mon Jan 21 13:14:45 2008
@@ -0,0 +1,65 @@
+#########################################################################################
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#########################################################################################
+
+
+class Document:
+    def __init__(self):
+        self.reset()
+        
+    def reset(self):
+        self.next = None
+        self.dir = None
+        self.name = None
+        self.md5 = None
+        self.sha = None
+        self.ripemd= None
+        
+    def __setMd5(self, value):
+        if self.md5 == None:
+            self.md5 = value
+        else:
+            self.md5 = self.md5 + value
+        
+    def __setSha(self, value):
+        if self.sha == None:
+            self.sha = value
+        else:
+            self.sha = self.sha + value
+
+    def __setRipemd(self, value):
+        if self.ripemd == None:
+            self.ripemd = value
+        else:
+            self.ripemd = self.ripemd + value
+        
+    def start_element(self, name, attrs):
+        if name == 'document':
+            print attrs
+            self.name = attrs.get('name')
+            self.dir = attrs.get('dir')
+        elif name == 'md5':
+            self.next = self.__setMd5
+        elif name == 'sha512':
+            self.next = self.__setSha
+        elif name == 'ripemd160':
+            self.next = self.__setRipemd
+        else:
+            self.next = None
+    
+    def end_element(self, name):
+        pass
+    
+    def char_data(self, data):
+        if not self.next == None:
+            self.next(data.strip())
\ No newline at end of file

Modified: incubator/public/trunk/scanner.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/scanner.py?rev=614011&r1=614010&r2=614011&view=diff
==============================================================================
--- incubator/public/trunk/scanner.py (original)
+++ incubator/public/trunk/scanner.py Mon Jan 21 13:14:45 2008
@@ -68,4 +68,5 @@
     scanner = Scanner('/www/archive.apache.org/dist/incubator')
     print scanner.scan()
     
-scanIncubatorReleases()
\ No newline at end of file
+if __name__ == '__main__':
+    scanIncubatorReleases()
\ No newline at end of file

Added: incubator/public/trunk/tests.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/tests.py?rev=614011&view=auto
==============================================================================
--- incubator/public/trunk/tests.py (added)
+++ incubator/public/trunk/tests.py Mon Jan 21 13:14:45 2008
@@ -0,0 +1,41 @@
+#########################################################################################
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#########################################################################################
+
+import scanner
+import unittest
+import diff
+import xml.parsers.expat
+
+class ReadXmlTestCase(unittest.TestCase):
+    
+    def testReadOne(self):
+        document = diff.Document()
+        parser = xml.parsers.expat.ParserCreate()
+        parser.StartElementHandler = document.start_element
+        parser.EndElementHandler = document.end_element
+        parser.CharacterDataHandler = document.char_data
+        parser.Parse("""<?xml version="1.0"?>
+ <document dir='a directory' name='a name' >
+  <md5>MD5 SUM</md5>
+  <sha512>SHA SUM</sha512>
+  <ripemd160>RIPEMD</ripemd160>
+ </document>""", 1)
+        
+        self.assertEqual('a directory', document.dir)
+        self.assertEqual('a name', document.name)
+        self.assertEqual('MD5 SUM', document.md5)
+        self.assertEqual('SHA SUM', document.sha)
+        self.assertEqual('RIPEMD', document.ripemd)
+        
+    
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message