def __d2r(self): logging.debug("Pushing dialogs into resources...") if isSystemLevelDialog(self.__input): logging.debug("\tDialogs file is System level.") file = SysDialogFile( self.__input ) file.load() for cpath,name in self.__output: resource = scanRCFile(cpath) if not self.__validLangcode(resource._langcode): logging.debug("\t\tIgnoring '%s' because its not the right langcode. @> %s"%(name,cpath)) continue try: projFile = file.genProjLevelFile( resource._name, '' ) except KeyError: logging.warning("Project %s does not exist in %s"%(resource._name, self.__input)) continue resource.updateDialogs(projFile) else: logging.debug("\tDialogs file is Project or language Level.") projFile = RCDialogFile( self.__input ) projFile.load() langs = projFile._table.getPossibleLangs() for cpath,name in self.__output: resource = scanRCFile(cpath) if not self.__validLangcode(resource._langcode): logging.debug("\t\tIgnoring '%s' because its not the right langcode. @> %s"%(name,cpath)) continue if resource._langcode in langs: logging.debug("\t\tUpdating %s @> %s"%(name,cpath)) resource.updateDialogs(projFile) else: raise MissingLangCodeError()
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
def __init__(self, path): if not isSystemLevelDialog( path ): raise TypeError("Path given is not a system level dialog file.") super().__init__( path ) self.setHasSections( True ) self._projs = {} #map: "projName" -> [RCDialogs]