[totem] opensubtitles: Fix/Disable some pylint warnings



commit e1b161e99950c9f40cdae0f8c8e45c729f97fc8a
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Dec 21 10:51:10 2011 +0000

    opensubtitles: Fix/Disable some pylint warnings

 src/plugins/opensubtitles/hash.py          |   14 +++++++-------
 src/plugins/opensubtitles/opensubtitles.py |    6 ++++--
 2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/opensubtitles/hash.py b/src/plugins/opensubtitles/hash.py
index d81e588..a69a90f 100644
--- a/src/plugins/opensubtitles/hash.py
+++ b/src/plugins/opensubtitles/hash.py
@@ -1,6 +1,6 @@
 import struct
 import os
-from gi.repository import Gio
+from gi.repository import Gio # pylint: disable-msg=E0611
 
 SIZE_ERROR = -1
 SEEK_ERROR = -2
@@ -21,26 +21,26 @@ def hash_file (name):
     if filesize < 65536 * 2:
         return SIZE_ERROR, 0
 
-    f = file(file_to_hash.get_path(), "rb")
+    file_handle = file (file_to_hash.get_path (), "rb")
 
     for _ in range (65536 / bytesize):
-        buf = f.read (bytesize)
+        buf = file_handle.read (bytesize)
         (l_value,) = struct.unpack (longlongformat, buf)
         file_hash += l_value
         file_hash = file_hash & 0xFFFFFFFFFFFFFFFF #to remain as 64bit number
 
-    f.seek (max (0, filesize - 65536), os.SEEK_SET)
+    file_handle.seek (max (0, filesize - 65536), os.SEEK_SET)
 
-    if f.tell() != max (0, filesize - 65536):
+    if file_handle.tell() != max (0, filesize - 65536):
         return SEEK_ERROR, 0
 
     for _ in range (65536/bytesize):
-        buf = f.read (bytesize)
+        buf = file_handle.read (bytesize)
         (l_value,) = struct.unpack (longlongformat, buf)
         file_hash += l_value
         file_hash = file_hash & 0xFFFFFFFFFFFFFFFF
 
-    f.close ()
+    file_handle.close ()
     returnedhash = "%016x" % file_hash
 
     print returnedhash
diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py
index dd7a04d..5f53034 100644
--- a/src/plugins/opensubtitles/opensubtitles.py
+++ b/src/plugins/opensubtitles/opensubtitles.py
@@ -371,7 +371,8 @@ class OpenSubtitlesModel (object):
 
         return (None, message)
 
-class OpenSubtitles (GObject.Object, Peas.Activatable):
+class OpenSubtitles (GObject.Object, # pylint: disable-msg=R0902
+                     Peas.Activatable):
     __gtype_name__ = 'OpenSubtitles'
 
     object = GObject.property (type = GObject.Object)
@@ -662,7 +663,8 @@ class OpenSubtitles (GObject.Object, Peas.Activatable):
             subtitle_file = Gio.file_new_for_uri (filename)
             suburi = subtitle_file.get_uri ()
 
-            sub_file = subtitle_file.replace ('', False, Gio.FileCreateFlags.REPLACE_DESTINATION, None)
+            flags = Gio.FileCreateFlags.REPLACE_DESTINATION
+            sub_file = subtitle_file.replace ('', False, flags, None)
             sub_file.write (subtitles, None)
             sub_file.close (None)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]