[Python-modules-commits] [python-exif] 03/19: Update utils.py

Wolfgang Borgert debacle at moszumanska.debian.org
Mon Oct 6 22:18:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to reference refs/remotes/upstream/develop
in repository python-exif.

commit 0dffeda46ae77fea9254f4611297e55a203fd4a3
Author: velis74 <jure.erznoznik at gmail.com>
Date:   Mon Oct 28 04:14:29 2013 +0100

    Update utils.py
    
    str / bytes coexistence support
---
 exifread/utils.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/exifread/utils.py b/exifread/utils.py
index ad6f931..0b09aa2 100644
--- a/exifread/utils.py
+++ b/exifread/utils.py
@@ -1,5 +1,10 @@
 
 
+def ord_(dta):
+    if isinstance(dta, str):
+        return ord(dta)
+    return dta
+
 def make_string(seq):
     """
     Don't throw an exception when given an out of range character.
@@ -24,14 +29,14 @@ def make_string_uc(seq):
     seq = seq[8:]
     # Of course, this is only correct if ASCII, and the standard explicitly
     # allows JIS and Unicode.
-    return make_string( make_string(seq) )
+    return make_string(seq)
 
 
 def s2n_motorola(str):
     """Extract multibyte integer in Motorola format (little endian)."""
     x = 0
     for c in str:
-        x = (x << 8) | ord(c)
+        x = (x << 8) | ord_(c)
     return x
 
 
@@ -40,7 +45,7 @@ def s2n_intel(str):
     x = 0
     y = 0
     for c in str:
-        x = x | (ord(c) << y)
+        x = x | (ord_(c) << y)
         y = y + 8
     return x
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-exif.git



More information about the Python-modules-commits mailing list