Fix bugs and some warnings by flake8
authorOleg Broytman <phd@phdru.name>
Wed, 20 Nov 2013 04:17:35 +0000 (08:17 +0400)
committerOleg Broytman <phd@phdru.name>
Wed, 20 Nov 2013 04:25:31 +0000 (08:25 +0400)
torrent
torrent-ANNOUNCE
xml

diff --git a/torrent b/torrent
index 6b770cb..b0d1e00 100755 (executable)
--- a/torrent
+++ b/torrent
@@ -28,13 +28,13 @@ year. The filesystem is, naturally, read-only.
 
 """
 
-__version__ = "1.2.0"
+__version__ = "1.2.1"
 __author__ = "Oleg Broytman <phd@phdru.name>"
 __copyright__ = "Copyright (C) 2010-2013 PhiloSoft Design"
 __license__ = "GPL"
 
 
-import sys, os
+import sys
 from eff_bdecode import decode
 
 try:
@@ -135,7 +135,7 @@ def mctorrent_list():
                         path = path.decode(encoding, 'replace').encode(default_encoding, 'replace')
             length = file['length']
             paths.append((path, length))
-    else: # One-file torrent
+    else:  # One-file torrent
         if 'length' not in info:
             torrent_error('Unknown length')
         length = info['length']
@@ -189,7 +189,6 @@ def mctorrent_copyout():
                 'nodes', 'publisher', 'publisher-url':
         if name == 'comment' and 'comment.utf-8' in torrent:
             data = torrent['comment.utf-8'].decode('utf-8').encode(default_encoding, 'replace')
-            meta.append(('.META/' + name, len(data)))
         elif torrent_filename == '.META/' + name:
             if name in torrent:
                 if name == 'announce-list':
index 77a56ef..ea67aec 100644 (file)
@@ -6,6 +6,9 @@ WHAT IS IT
 Midnight Commander.
 
 
+WHAT'S NEW in version 1.2.1 (2013-11-20)
+   Fixed a minor bug.
+
 WHAT'S NEW in version 1.2.0 (2013-11-16)
    Get charset from the environment.
 
diff --git a/xml b/xml
index 3d40d37..5ed82db 100755 (executable)
--- a/xml
+++ b/xml
@@ -42,8 +42,8 @@ __author__ = "Oleg Broytman <phd@phdru.name>"
 __copyright__ = "Copyright (C) 2013 PhiloSoft Design"
 __license__ = "GPL"
 
-default_implementation = None # Can be None for default choice,
-                              # 'lxml', 'elementtree' or 'minidom'
+default_implementation = None  # Can be None for default choice,
+                               # 'lxml', 'elementtree' or 'minidom'
 
 use_minidom = True
 use_elementtree = False
@@ -143,7 +143,7 @@ class MiniDOMXmlVfs(XmlVfs):
 
     def attrs2text(self, node):
         attrs = node.attributes
-        attrs = [attrs.item(i) for i in range (attrs.length)]
+        attrs = [attrs.item(i) for i in range(attrs.length)]
         return '\n'.join(["%s=%s" %
             (a.name.encode(default_encoding, "replace"),
             a.value.encode(default_encoding, "replace"))
@@ -170,7 +170,7 @@ class MiniDOMXmlVfs(XmlVfs):
             if element.localName:
                 n += 1
         if n:
-            width = int(math.log10(n))+1
+            width = int(math.log10(n)) + 1
             template = "%%0%dd" % width
         else:
             template = "%d"
@@ -240,26 +240,26 @@ if use_elementtree:
 
             class PIParser(ET.XMLTreeBuilder):
 
-               def __init__(self):
-                   ET.XMLTreeBuilder.__init__(self)
-                   # assumes ElementTree 1.2.X
-                   self._parser.CommentHandler = self.handle_comment
-                   self._parser.ProcessingInstructionHandler = self.handle_pi
-                   self._target.start("document", {})
-
-               def close(self):
-                   self._target.end("document")
-                   return ET.XMLTreeBuilder.close(self)
-
-               def handle_comment(self, data):
-                   self._target.start(ET.Comment, {})
-                   self._target.data(data)
-                   self._target.end(ET.Comment)
-
-               def handle_pi(self, target, data):
-                   self._target.start(ET.PI, {})
-                   self._target.data(target + " " + data)
-                   self._target.end(ET.PI)
+                def __init__(self):
+                    ET.XMLTreeBuilder.__init__(self)
+                    # assumes ElementTree 1.2.X
+                    self._parser.CommentHandler = self.handle_comment
+                    self._parser.ProcessingInstructionHandler = self.handle_pi
+                    self._target.start("document", {})
+
+                def close(self):
+                    self._target.end("document")
+                    return ET.XMLTreeBuilder.close(self)
+
+                def handle_comment(self, data):
+                    self._target.start(ET.Comment, {})
+                    self._target.data(data)
+                    self._target.end(ET.Comment)
+
+                def handle_pi(self, target, data):
+                    self._target.start(ET.PI, {})
+                    self._target.data(target + " " + data)
+                    self._target.end(ET.PI)
 
             self.document = ET.parse(sys.argv[2], PIParser())