[Debtorrent-commits] r8 - /debtorrent/trunk/btshowmetainfo.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Wed Apr 25 22:15:18 UTC 2007


Author: camrdale-guest
Date: Wed Apr 25 22:15:18 2007
New Revision: 8

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=8
Log:
Modify btshowmetainfo file to work with dtorrents

Modified:
    debtorrent/trunk/btshowmetainfo.py

Modified: debtorrent/trunk/btshowmetainfo.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/btshowmetainfo.py?rev=8&op=diff
==============================================================================
--- debtorrent/trunk/btshowmetainfo.py (original)
+++ debtorrent/trunk/btshowmetainfo.py Wed Apr 25 22:15:18 2007
@@ -16,7 +16,7 @@
 print
 
 if len(argv) == 1:
-    print '%s file1.torrent file2.torrent file3.torrent ...' % argv[0]
+    print '%s file1.dtorrent file2.dtorrent file3.dtorrent ...' % argv[0]
     print
     exit(2) # common exit code for syntax error
 
@@ -29,29 +29,21 @@
 
     print 'metainfo file.: %s' % basename(metainfo_name)
     print 'info hash.....: %s' % info_hash.hexdigest()
-    piece_length = info['piece length']
-    if info.has_key('length'):
-        # let's assume we just have a file
-        print 'file name.....: %s' % info['name']
-        file_length = info['length']
-        name ='file size.....:'
-    else:
-        # let's assume we have a directory structure
-        print 'directory name: %s' % info['name']
-        print 'files.........: '
-        file_length = 0;
-        for file in info['files']:
-            path = ''
-            for item in file['path']:
-                if (path != ''):
-                   path = path + "/"
-                path = path + item
-            print '   %s (%d)' % (path, file['length'])
-            file_length += file['length']
-            name ='archive size..:'
-    piece_number, last_piece_length = divmod(file_length, piece_length)
-    print '%s %i (%i * %i + %i)' \
-          % (name,file_length, piece_number, piece_length, last_piece_length)
+    piece_lengths = info['piece lengths']
+    print 'directory name: %s' % info['name']
+    print 'files.........: '
+    file_length = 0;
+    for file in info['files']:
+        path = ''
+        for item in file['path']:
+            if (path != ''):
+                path = path + "/"
+            path = path + item
+        print '   %s (%d)' % (path, file['length'])
+        file_length += file['length']
+        name ='archive size..:'
+    print '%s %i bytes (%i pieces)' \
+          % (name,file_length, len(piece_lengths))
     print 'announce url..: %s' % metainfo['announce']
     if metainfo.has_key('announce-list'):
         list = []




More information about the Debtorrent-commits mailing list