예제 #1
0
 def __loadDataMap(self, langcodes, lines):
     for line in lines:
         if len(line) < 2: continue
         xpathid, *langvals = line
         val = RCStringValue()
         try:
             for lang in langcodes:
                 val.addValuePair(lang, langvals.pop(0))
         except IndexError: pass
         self.__data[ xpathid ] = val
예제 #2
0
 def __loadUtilLines(self):
     rows = self.__readSheet( TranslationFile.UTIL_SHEET, 1 )
     langcodes = []
     headeroffset = len(TranslationFile.HEADER_COLS)
     for head in rows:
         langcodes = head[headeroffset:]
         break
     langcodes = self.__translateCodes( langcodes )
     projOrUtil = 0 # 0=proj,1=util,2=seps,3=pruned
     
     for row in rows: 
         if row[0] == "PROJMAP":
             projOrUtil = 0
             continue
         elif row[0] == "XMLUTIL":
             projOrUtil = 1
             continue
         elif row[0] == "SEPS":
             projOrUtil = 2
             continue
         elif row[0] == "PRUNED":
             projOrUtil = 3
             continue
         elif IDMatcher.search(row[0]) is not None:
             if projOrUtil==1 and row[1].isdigit():
                 idn, order, typeid, *_ = row #ignore the man behind the curtain
                 self.__utils[idn] = (order, typeid)
             elif projOrUtil==2:
                 self.__seps.append( row[0] )
             elif projOrUtil==3:
                 midlist=row[0].split(",")
                 col = 1
                 val = RCStringValue()
                 for lang in langcodes:
                     val.addValuePair(lang, row[col])
                     col+=1
                 mid = uuid.uuid4()
                 self.__mergelist[mid]=midlist
                 self.__pruned[mid]=val
             else:
                 #sometimes a project name might match an ID, in 
                 # these instances we have to be careful.
                 if projOrUtil==0 and row[1].isdigit() and self.__rest(2, row, ''):
                     self.__projs[ row[0] ] = row[1]
                 else:
                     logging.debug("UNKNOWN UTIL LINE: %s, state=(%d)"%(row, projOrUtil))
                     continue #broken line?
         else:
             if projOrUtil==0 and row[1].isdigit():
                 self.__projs[ row[0] ] = row[1]
             else: 
                 logging.debug("UNKNOWN UTIL LINE: %s"%row)
                 continue #broken line?
예제 #3
0
 def load(self, newpath=None):
     offset = RCStrTblFile.CONTROL_COLS
     header = self.getHeader( RCStrTblFile.HEADER_ROW )
     if len(header) < offset: 
         raise Exception("File does not have enough control columns.")
     
     langcodes = len(header)-offset;
     sections = self.readSection(RCStrTblFile.HEADER_ROW+1)
     for secname, entries in sections:
         name = self.__cleanName( secname )
         self._projs[name] = RCStrTbl()
         for entry in entries:
             value = RCStringValue(entry[0])
             for c in range(langcodes):
                 value.addValuePair(header[offset+c], entry[offset+c])
             self._projs[name].addStringValue( value )
     self.__loaded = True
예제 #4
0
    def load(self):
        """Load the string tables into memory."""
        offset = RCStrTblFile.CONTROL_COLS
        header = self.getHeader(RCStrTblFile.HEADER_ROW)
        if len(header) < offset:
            raise Exception("File does not have enough control columns.")

        langcodes = len(header) - offset
        lines = self.readLine(RCStrTblFile.HEADER_ROW + 1)
        self._table = RCStrTbl()
        for line in lines:  # For each line add it to the string table
            value = RCStringValue(line[0])  # id
            ####################################
            # For each langcode column add it to the string value.
            for c in range(langcodes):
                value.addValuePair(header[offset + c], line[offset + c])
            self._table._values.append(value)
        return True
예제 #5
0
 def __loadStringLines(self):
     global IDMatcher
     rows = self.__readSheet( TranslationFile.STRINGS_SHEET, 0 )
     langcodes = []
     headeroffset = len(TranslationFile.HEADER_COLS)
     for head in rows:
         langcodes = head[headeroffset:]
         break
     langcodes = self.__translateCodes( langcodes )
     for row in rows:
         midlist=row[0].split(",")
         col = 1
         val = RCStringValue()
         for lang in langcodes:
             val.addValuePair(lang, row[col])
             col+=1
         #add value 
         for idn in midlist: self.__addStringLine(idn, val) #OMG SO SLOW, but it works
예제 #6
0
 def load(self, newpath=None):
     if newpath is not None:
         if not isSystemLevelDialog( newpath ):
             raise TypeError("Path given is not a system level dialog file.")
         else: self._path = newpath
     self._projs = {}
     offset = RCDialogFile.CONTROL_COLS
     header = self.getHeader( RCDialogFile.HEADER_ROW )
     langcodes = len(header)-offset;
     sections = self.readSection()
     for secname, entries in sections:
         name, lid = self.__splitSectionName(secname)
         if name not in self._projs: self._projs[name]=[]
         dialog = RCDialog(lid)
         for entry in entries:
             value = RCStringValue(entry[0]) #id
             for c in range(langcodes):
                 value.addValuePair(header[offset+c], entry[offset+c])
             dialog._values.append(value)
         self._projs[name].append( dialog )
     self.__loaded = True
예제 #7
0
 def load(self):
     """Load the dialogs into memory."""
     offset = RCDialogFile.CONTROL_COLS
     header = self.getHeader( RCDialogFile.HEADER_ROW )
     if len(header) < offset: 
         raise Exception("File does not have enough control columns.")
     
     langcodes = len(header)-offset;
     sections = self.readSection(0)
     for name, entries in sections: #For each section make a dialog
         dialog = RCDialog( name )
         #For each entry add it as a string value to the dialog
         for entry in entries: 
             value = RCStringValue(entry[0]) #id
             ####################################
             ## Here is where you would add other control cols
             self.__loadFromLine( entry, dialog )
             ####################################
             # For each langcode column add it to the string value.
             for c in range(langcodes):
                 value.addValuePair(header[offset+c], entry[offset+c])
             dialog._values.append(value)
         self._dialogs.append( dialog )
     return True