summaryrefslogtreecommitdiffstats
path: root/bindings/python/gtkpod.py
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/python/gtkpod.py')
-rw-r--r--bindings/python/gtkpod.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/bindings/python/gtkpod.py b/bindings/python/gtkpod.py
index 64e50f2..83193f5 100644
--- a/bindings/python/gtkpod.py
+++ b/bindings/python/gtkpod.py
@@ -1,9 +1,17 @@
"""Read and write Gtkpod extended info files."""
-import sha
import os
import types
+# The hashlib module is only available in python >= 2.5,
+# while the sha module is deprecated in 2.6.
+try:
+ import hashlib
+ sha1 = hashlib.sha1
+except ImportError:
+ import sha
+ sha1 = sha.sha
+
# This file is originally stolen from pypod-0.5.0
# http://superduper.net/index.py?page=pypod
# and reworked significantly since then.
@@ -21,7 +29,7 @@ def sha1_hash(filename):
import struct
# only hash the first 16k
hash_len = 4*4096
- hash = sha.sha()
+ hash = sha1()
size = os.path.getsize(filename)
hash.update(struct.pack("<L", size))
hash.update(open(filename).read(hash_len))