diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2011-12-21 10:51:10 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2011-12-21 10:51:10 +0000 |
commit | e1b161e99950c9f40cdae0f8c8e45c729f97fc8a (patch) | |
tree | 37ba4178222828ce7f7578b104063b9e2d38e54b | |
parent | 709d550a4d110162a3436803f96dc0d00c4db5f0 (diff) | |
download | totem-e1b161e99950c9f40cdae0f8c8e45c729f97fc8a.tar.gz |
opensubtitles: Fix/Disable some pylint warnings
-rw-r--r-- | src/plugins/opensubtitles/hash.py | 14 | ||||
-rw-r--r-- | 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 d81e58865..a69a90f32 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 dd7a04dde..5f5303476 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) |