Skip to content

Commit

Permalink
Merge pull request #1 from rcohen2000/master
Browse files Browse the repository at this point in the history
Python 3 compatibility.
  • Loading branch information
chrisballinger committed Aug 12, 2016
2 parents 137f3d2 + 5ff3e8a commit 15d3bf2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions localizable.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _get_content(filename=None, content=None):
return _get_content_from_file(filename, format_encoding)

def _get_content_from_file(filename, encoding):
f = open(filename, 'r')
f = open(filename, 'rb')
try:
content = f.read()
if chardet.detect(content)['encoding'].startswith(format_encoding):
Expand All @@ -52,11 +52,11 @@ def _get_content_from_file(filename, encoding):
f.close()
f = codecs.open(filename, 'r', encoding=encoding)
return f.read()
except IOError, e:
print "Error opening file %s with encoding %s: %s" %\
(filename, format_encoding, e.message)
except Exception, e:
print "Unhandled exception: %s" % e.message
except IOError as e:
print("Error opening file %s with encoding %s: %s" %\
(filename, format_encoding, e.message))
except Exception as e:
print("Unhandled exception: %s" % e.message)
finally:
f.close()

Expand Down Expand Up @@ -94,10 +94,10 @@ def parse_strings(content="", filename=None):
while end < start:
m = c.match(f, end, start) or ws.match(f, end, start)
if not m or m.start() != end:
print "Invalid syntax: %s" %\
f[end:start]
print("Invalid syntax: %s" %\
f[end:start])
end = m.end()
end = end_
key = _unescape_key(key)
stringset.append({'key': key, 'value': _unescape(value), 'comment': comment})
return stringset
return stringset

0 comments on commit 15d3bf2

Please sign in to comment.