@@ -40,7 +40,7 @@ def _get_content(filename=None, content=None):
4040 return _get_content_from_file (filename , format_encoding )
4141
4242def _get_content_from_file (filename , encoding ):
43- f = open (filename , 'r ' )
43+ f = open (filename , 'rb ' )
4444 try :
4545 content = f .read ()
4646 if chardet .detect (content )['encoding' ].startswith (format_encoding ):
@@ -52,11 +52,11 @@ def _get_content_from_file(filename, encoding):
5252 f .close ()
5353 f = codecs .open (filename , 'r' , encoding = encoding )
5454 return f .read ()
55- except IOError , e :
56- print "Error opening file %s with encoding %s: %s" % \
57- (filename , format_encoding , e .message )
58- except Exception , e :
59- print "Unhandled exception: %s" % e .message
55+ except IOError as e :
56+ print ( "Error opening file %s with encoding %s: %s" % \
57+ (filename , format_encoding , e .message ))
58+ except Exception as e :
59+ print ( "Unhandled exception: %s" % e .message )
6060 finally :
6161 f .close ()
6262
@@ -94,10 +94,10 @@ def parse_strings(content="", filename=None):
9494 while end < start :
9595 m = c .match (f , end , start ) or ws .match (f , end , start )
9696 if not m or m .start () != end :
97- print "Invalid syntax: %s" % \
98- f [end :start ]
97+ print ( "Invalid syntax: %s" % \
98+ f [end :start ])
9999 end = m .end ()
100100 end = end_
101101 key = _unescape_key (key )
102102 stringset .append ({'key' : key , 'value' : _unescape (value ), 'comment' : comment })
103- return stringset
103+ return stringset
0 commit comments