Kaydet (Commit) 1a2ea259 authored tarafından László Németh's avatar László Németh

some Python 3.3 port (not important for LO 4.0)

Change-Id: Id151d59a9bab2454b9d359aefb5c35a9f05bb9ce
üst 02e22028
...@@ -22,7 +22,7 @@ import sys ...@@ -22,7 +22,7 @@ import sys
localeNames = {'fr': 'French', 'hu': 'Hungarian', 'de': 'German'} localeNames = {'fr': 'French', 'hu': 'Hungarian', 'de': 'German'}
def getLocaleName (code): def getLocaleName (code):
global localeNames global localeNames
if localeNames.has_key(code): if code in localeNames:
return localeNames[code] return localeNames[code]
else: else:
return "(unknown locale)" return "(unknown locale)"
...@@ -39,7 +39,7 @@ class LocaleData(object): ...@@ -39,7 +39,7 @@ class LocaleData(object):
self.funcList = {} self.funcList = {}
def addKeywordMap (self, funcName, localeName, engName): 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] = []
self.funcList[funcName].append([localeName, engName]) self.funcList[funcName].append([localeName, engName])
...@@ -54,13 +54,12 @@ class LocaleData(object): ...@@ -54,13 +54,12 @@ class LocaleData(object):
chars += "// " + "-"*75 + "\n" chars += "// " + "-"*75 + "\n"
chars += "// %s language locale (automatically generated)\n"%getLocaleName(self.locale) chars += "// %s language locale (automatically generated)\n"%getLocaleName(self.locale)
chars += "// " + "-"*75 + "\n" 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 += self.locale
chars += "\"), OUString(), OUString());\n\n" chars += "\")), OUString(), OUString());\n\n"
# pre instantiations of localized function names. # pre instantiations of localized function names.
funcs = self.funcList.keys() funcs = sorted(self.funcList.keys())
funcs.sort()
chars += "// pre instantiations of localized function names\n" chars += "// pre instantiations of localized function names\n"
for func in funcs: for func in funcs:
for item in self.funcList[func]: for item in self.funcList[func]:
...@@ -115,9 +114,12 @@ class Parser(object): ...@@ -115,9 +114,12 @@ class Parser(object):
def getDByte (self): def getDByte (self):
# Assume little endian. # Assume little endian.
bh = ord(self.bytes[self.i]) bh = self.bytes[self.i]
bl = ord(self.bytes[self.i+1]) bl = self.bytes[self.i+1]
dbyte = bl*256 + bh try:
dbyte = ord(bl)*256 + ord(bh)
except:
dbyte = bl*256 + bh
self.i += 2 self.i += 2
return dbyte return dbyte
...@@ -134,11 +136,11 @@ class Parser(object): ...@@ -134,11 +136,11 @@ class Parser(object):
for item in buf: for item in buf:
sys.stdout.write(chr(item)) sys.stdout.write(chr(item))
if linefeed: if linefeed:
print '' print ('')
def parse (self): def parse (self):
file = open(self.infile, 'r') file = open(self.infile, 'rb')
self.bytes = file.read() self.bytes = file.read()
file.close() file.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment