diff options
author | László Németh <nemeth@numbertext.org> | 2012-12-10 17:08:23 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2012-12-10 17:15:56 +0100 |
commit | 1a2ea259717e8cebf9744ceb92acc34efaef443b (patch) | |
tree | fd83fff38c0f3c6f9b7bb86395dc9608122b017a /sc/workben/celltrans | |
parent | 02e2202894652751f59a0709e1b767e8ed2ab30c (diff) |
some Python 3.3 port (not important for LO 4.0)
Change-Id: Id151d59a9bab2454b9d359aefb5c35a9f05bb9ce
Diffstat (limited to 'sc/workben/celltrans')
-rw-r--r-- | sc/workben/celltrans/parse.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/sc/workben/celltrans/parse.py b/sc/workben/celltrans/parse.py index 74a7279d5d35..a80c4311b3f0 100644 --- a/sc/workben/celltrans/parse.py +++ b/sc/workben/celltrans/parse.py @@ -22,7 +22,7 @@ import sys localeNames = {'fr': 'French', 'hu': 'Hungarian', 'de': 'German'} def getLocaleName (code): global localeNames - if localeNames.has_key(code): + if code in localeNames: return localeNames[code] else: return "(unknown locale)" @@ -39,7 +39,7 @@ class LocaleData(object): self.funcList = {} def addKeywordMap (self, funcName, localeName, engName): - if not self.funcList.has_key(funcName): + if not funcName in self.funcList: self.funcList[funcName] = [] self.funcList[funcName].append([localeName, engName]) @@ -54,13 +54,12 @@ class LocaleData(object): chars += "// " + "-"*75 + "\n" chars += "// %s language locale (automatically generated)\n"%getLocaleName(self.locale) chars += "// " + "-"*75 + "\n" - chars += "static const Locale a" + self.locale.capitalize() + "(OUString::createFromAscii(\"" + chars += "static const Locale a" + self.locale.capitalize() + "(OUString(RTL_CONSTASCII_USTRINGPARAM(\"" chars += self.locale - chars += "\"), OUString(), OUString());\n\n" + chars += "\")), OUString(), OUString());\n\n" # pre instantiations of localized function names. - funcs = self.funcList.keys() - funcs.sort() + funcs = sorted(self.funcList.keys()) chars += "// pre instantiations of localized function names\n" for func in funcs: for item in self.funcList[func]: @@ -115,9 +114,12 @@ class Parser(object): def getDByte (self): # Assume little endian. - bh = ord(self.bytes[self.i]) - bl = ord(self.bytes[self.i+1]) - dbyte = bl*256 + bh + bh = self.bytes[self.i] + bl = self.bytes[self.i+1] + try: + dbyte = ord(bl)*256 + ord(bh) + except: + dbyte = bl*256 + bh self.i += 2 return dbyte @@ -134,11 +136,11 @@ class Parser(object): for item in buf: sys.stdout.write(chr(item)) if linefeed: - print '' + print ('') def parse (self): - file = open(self.infile, 'r') + file = open(self.infile, 'rb') self.bytes = file.read() file.close() |