diff options
-rw-r--r-- | net-p2p/py-ed2k-tools/files/patch-ed2k__metutils.py | 33 | ||||
-rw-r--r-- | net-p2p/py-ed2k-tools/files/patch-temp__summary.py | 20 |
2 files changed, 40 insertions, 13 deletions
diff --git a/net-p2p/py-ed2k-tools/files/patch-ed2k__metutils.py b/net-p2p/py-ed2k-tools/files/patch-ed2k__metutils.py index 7cd01f6f60d3..7c4cfa1ac8ee 100644 --- a/net-p2p/py-ed2k-tools/files/patch-ed2k__metutils.py +++ b/net-p2p/py-ed2k-tools/files/patch-ed2k__metutils.py @@ -1,6 +1,6 @@ --- ed2k_metutils.py.orig 2003-05-06 11:53:14 UTC +++ ed2k_metutils.py -@@ -6,7 +6,6 @@ +@@ -6,24 +6,24 @@ # tested on macosx 10.2.4, python 2.2 import struct; @@ -8,9 +8,10 @@ import sys; # Some defines. -@@ -14,16 +13,16 @@ import sys; + TAG_TYPE_STRING = 2; TAG_TYPE_INTEGER = 3; ++TAG_TYPE_BLOB = 7 -TAG_HANDLE_FILENAME = chr( 1 ); -TAG_HANDLE_FILESIZE = chr( 2 ); @@ -35,7 +36,7 @@ class MetFile: """Class designed to hold the data of a .part.met file.""" -@@ -39,7 +38,7 @@ class MetFile: +@@ -39,7 +39,7 @@ class MetFile: # a .part file must exist, even if it's empty. The same doesn't apply for new overnet. self.version = 225; self.modDate = 0; @@ -44,7 +45,7 @@ return; header_struct = "<BI16sH"; -@@ -58,7 +57,7 @@ class MetFile: +@@ -58,7 +58,7 @@ class MetFile: dstore = dstore[ 4 : ]; for meta in range( n_meta ): @@ -53,7 +54,25 @@ dstore = dstore[ 1 : ]; name_len, = struct.unpack( "<H", dstore[ : 2 ] ); -@@ -81,14 +80,14 @@ class MetFile: +@@ -69,11 +69,16 @@ class MetFile: + if t_type == TAG_TYPE_INTEGER: + value, = struct.unpack( "<I", dstore[ : 4 ] ); + dstore = dstore[ 4 : ]; +- else: ++ elif t_type == TAG_TYPE_STRING: + value_len, = struct.unpack( "<H", dstore[ : 2 ] ); + dstore = dstore[ 2 : ]; + value, = struct.unpack( "<%is" % value_len, dstore[ : value_len ] ); + dstore = dstore[ value_len : ]; ++ elif t_type == TAG_TYPE_BLOB: ++ blen, = struct.unpack("<I", dstore[:4]) ++ # XXX: for now, just skip (ignore) the payload ++ dstore = dstore[4 + blen:] ++ continue + + self.AddTag( MetaTag( name, value, t_type ) ); + +@@ -81,14 +86,14 @@ class MetFile: """Return a string representation of the file MD4.""" data = ""; for i in range( len( self.fileID ) ): @@ -70,7 +89,7 @@ def ReduceToData( self ): """Reduce a class instance back into a stream suitable for writing to disk.""" -@@ -109,13 +108,13 @@ class MetFile: +@@ -109,13 +114,13 @@ class MetFile: """Return an array of tags matching the supplied handle. Tags relating to gaps do no obey the usual 'special tag' semantics, so set the flag to 1 if you are dealing with them.""" @@ -86,7 +105,7 @@ else: self.m_tags = [ x for x in self.m_tags if x.name != tagHandle ]; class MetaTag: -@@ -127,7 +126,7 @@ class MetaTag: +@@ -127,7 +132,7 @@ class MetaTag: self.value = value; if t_type == None: # Rudiments of Autodetection... diff --git a/net-p2p/py-ed2k-tools/files/patch-temp__summary.py b/net-p2p/py-ed2k-tools/files/patch-temp__summary.py index 46e7db596279..a18da6eceb96 100644 --- a/net-p2p/py-ed2k-tools/files/patch-temp__summary.py +++ b/net-p2p/py-ed2k-tools/files/patch-temp__summary.py @@ -1,9 +1,10 @@ --- temp_summary.py.orig 2003-05-06 11:53:14 UTC +++ temp_summary.py -@@ -2,11 +2,9 @@ +@@ -1,12 +1,9 @@ + #!/usr/bin/python from ed2k_metutils import * import os - import stat +-import stat +import unicodedata -# I'm really surprised there's no easy way to get the terminal @@ -14,7 +15,7 @@ if __name__ == "__main__": # Here's an example to cut and keep. -@@ -15,13 +13,10 @@ if __name__ == "__main__": +@@ -15,26 +12,22 @@ if __name__ == "__main__": # see how much data I actually got from night to night. if len( sys.argv ) < 2: @@ -32,7 +33,14 @@ sys.exit( -1 ); total_size = total_down = 0; -@@ -34,7 +29,7 @@ if __name__ == "__main__": + +- sta = os.stat( sys.argv[ 1 ] )[ 0 ]; +- if stat.S_ISDIR( sta ): +- mets = [ "%s%s" % ( sys.argv[ 1 ], x ) for x in os.listdir( sys.argv[ 1 ] ) if x.endswith( ".met" ) ]; ++ if os.path.isdir(sys.argv[1]): ++ mets = [ "%s/%s" % (sys.argv[1], x) for x in os.listdir(sys.argv[1]) if x.endswith(".met") ] + else: + mets = sys.argv[ 1 : ]; for met_file in mets: @@ -41,7 +49,7 @@ data = fh.read(); fh.close(); -@@ -43,7 +38,7 @@ if __name__ == "__main__": +@@ -43,7 +36,7 @@ if __name__ == "__main__": # We're interested in the name, the total size, and some kind of... anti-gapping. size = met_data.FindTags( TAG_HANDLE_FILESIZE )[ 0 ].value; @@ -50,7 +58,7 @@ # Set the total downloaded to the file size. down = size; -@@ -71,19 +66,42 @@ if __name__ == "__main__": +@@ -71,19 +64,42 @@ if __name__ == "__main__": bar = "#" * ( WIDTH - 2 ); for gap in gaps: gap_start, gap_end = gaps[ gap ]; |