diff options
author | Devan Franchini <twitch153@gentoo.org> | 2013-10-18 23:24:15 -0400 |
---|---|---|
committer | Devan Franchini <twitch153@gentoo.org> | 2013-10-28 22:13:58 -0400 |
commit | a7b03c25292bfad034c8ef91a8f6f50199bc67e8 (patch) | |
tree | 5f40b7556c105e927b773558336728b9ce1426dc | |
parent | WebappConfig/db.py: Converts keys.packages.keys() into a list. (diff) | |
download | webapp-config-a7b03c25292bfad034c8ef91a8f6f50199bc67e8.tar.gz webapp-config-a7b03c25292bfad034c8ef91a8f6f50199bc67e8.tar.bz2 webapp-config-a7b03c25292bfad034c8ef91a8f6f50199bc67e8.zip |
WebappConfig/compat.py: Revamps create_md5() function.
This second revamp changes the way in which python is opening
the file to create an md5 hash of. Upon calling the open()
function it opens the file to read it, or as a binary. This
allows for consistent behavior when trying to open either a
binary file, or a text file to hash. This method is also much
cleaner and sufficient for forward and backwards compatibility.
Conflicts:
WebappConfig/compat.py
-rw-r--r-- | WebappConfig/compat.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/WebappConfig/compat.py b/WebappConfig/compat.py index 536bb2a..526b1bc 100644 --- a/WebappConfig/compat.py +++ b/WebappConfig/compat.py @@ -15,13 +15,18 @@ # # ======================================================================== -import hashlib, os, os.path, sys +import hashlib def create_md5(filename): +<<<<<<< HEAD if hex(sys.hexversion) >= '0x3020000': filename = open(filename).read() encoded_file = filename.encode('utf8') return str(hashlib.md5(encoded_file).hexdigest()) else: return str(hashlib.md5(open(filename).read()).hexdigest()) +======= + with open(filename, 'rb') as f: + return str(hashlib.md5(f.read()).hexdigest()) +>>>>>>> 04e9a55... WebappConfig/compat.py: Revamps create_md5() function. |