[gnome-commander/gcmd-1-2-8] Fixed problem #640387 (yet another fix for deprecated python modules: md5, sha1)



commit a409a75938698ead840b50f399779c9099f1c53d
Author: Alessio Treglia <alessio debian org>
Date:   Thu May 12 22:09:24 2011 +0200

    Fixed problem #640387 (yet another fix for deprecated python modules: md5, sha1)

 NEWS                              |    1 +
 doc/C/gnome-commander.xml         |    3 +++
 plugins/python/md5sum/md5sum.py   |   15 ++++++++-------
 plugins/python/sha1sum/sha1sum.py |   14 ++++++++------
 4 files changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/NEWS b/NEWS
index 723e133..fe003a9 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ gnome-commander 1.2.8.12
 ---------------
 
 Bug fixes:
+ * Fixed problem #640387 (yet another fix for deprecated python modules: md5, sha1)
  * Fixed problem #649375 (bookmarks not updated for newly added ones)
 
 
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index 72edfe5..57b9730 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -6089,6 +6089,9 @@
                 <para>
                     <itemizedlist>
                         <listitem>
+                            <para>Fixed problem #640387 (yet another fix for deprecated python modules: md5, sha1)</para>
+                        </listitem>
+                        <listitem>
                             <para>Fixed problem #649375 (bookmarks not updated for newly added ones)</para>
                         </listitem>
                     </itemizedlist>
diff --git a/plugins/python/md5sum/md5sum.py b/plugins/python/md5sum/md5sum.py
index cf8d740..3514b49 100644
--- a/plugins/python/md5sum/md5sum.py
+++ b/plugins/python/md5sum/md5sum.py
@@ -20,19 +20,20 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-import warnings
-
-warnings.simplefilter("ignore", DeprecationWarning)
-
 try:
     import gnomevfs
 except ImportError:
     import gnome.vfs as gnomevfs
 
 import os
+import sys
 import string
-import md5
-
+if sys.version_info[0] == 2 and sys.version_info[1] < 6:
+    import md5
+    md5_new = md5.new
+else:
+    from hashlib import md5
+    md5_new = md5
 
 def main(main_wnd_xid, active_cwd, inactive_cwd, selected_files):
     parent_dir = string.split(active_cwd, os.sep)[-1]
@@ -44,7 +45,7 @@ def main(main_wnd_xid, active_cwd, inactive_cwd, selected_files):
             f = file(active_cwd+os.sep+uri.short_name, 'rb')
             file_content = f.read()
             f.close()
-            md5sum = md5.new(file_content).hexdigest()
+            md5sum = md5_new(file_content).hexdigest()
             f_md5sum.write('%s  %s\n' % (md5sum, uri.short_name))
     f_md5sum.close()
     return True
diff --git a/plugins/python/sha1sum/sha1sum.py b/plugins/python/sha1sum/sha1sum.py
index eb2027d..39f2155 100644
--- a/plugins/python/sha1sum/sha1sum.py
+++ b/plugins/python/sha1sum/sha1sum.py
@@ -20,18 +20,20 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-import warnings
-
-warnings.simplefilter("ignore", DeprecationWarning)
-
 try:
     import gnomevfs
 except ImportError:
     import gnome.vfs as gnomevfs
 
 import os
+import sys
 import string
-import sha
+if sys.version_info[0] == 2 and sys.version_info[1] < 6:
+    import sha
+    sha_new = sha.new
+else:
+    from hashlib import sha1
+    sha_new = sha1
 
 
 def main(main_wnd_xid, active_cwd, inactive_cwd, selected_files):
@@ -44,7 +46,7 @@ def main(main_wnd_xid, active_cwd, inactive_cwd, selected_files):
             f = file(active_cwd+os.sep+uri.short_name, 'rb')
             file_content = f.read()
             f.close()
-            sha1sum = sha.new(file_content).hexdigest()
+            sha1sum = sha1_new(file_content).hexdigest()
             f_sha1sum.write('%s  %s\n' % (sha1sum, uri.short_name))
     f_sha1sum.close()
     return True



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