[Libreoffice-commits] .: sc/workben

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 10 08:16:26 PST 2012


 sc/workben/celltrans/parse.py |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

New commits:
commit 1a2ea259717e8cebf9744ceb92acc34efaef443b
Author: László Németh <nemeth at numbertext.org>
Date:   Mon Dec 10 17:08:23 2012 +0100

    some Python 3.3 port (not important for LO 4.0)
    
    Change-Id: Id151d59a9bab2454b9d359aefb5c35a9f05bb9ce

diff --git a/sc/workben/celltrans/parse.py b/sc/workben/celltrans/parse.py
index 74a7279..a80c431 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()
 


More information about the Libreoffice-commits mailing list