def __s2r(self): logging.debug("Pushing strings into resources...") if isSystemLevelStringTable(self.__input): logging.debug("\tString table file is System Level.") file = SysStrTblFile( 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.updateStringTables(projFile) else: logging.debug("\tString Table File is Project or Language Level.") projFile = RCStrTblFile( 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.updateStringTables(projFile) else: raise MissingLangCodeError()
def addProjLevelFile(self, projName, path, obj=None, overwrite=True): if not overwrite and projName in self._projs: raise KeyError("Project already exists!") if obj is not None: file = obj else: file = RCStrTblFile( path ) if not file.load(): raise Exception("Could not load String Table File: %s"%path) self._projs[projName] = copy.deepcopy( file._table ) return True
def ScanAndMergeStrings(newPath, stringFiles): """Scans all files in a list and merges them together to make a project level file. This is considered a merge since its RCStrTblFiles that are being utilized. If there is a problem scanning, then the error is raised. """ if len(stringFiles) < 1: return None from lslib.base.file.utility.StrTblFile import ScanStringTableFile, RCStrTblFile # find headers for this particular resource headers = _getHeadersFromPath( stringFiles[0]._path ) # scan all files with the headers, merging as we go. if len(stringFiles) == 1: mergedProjFile = copy.deepcopy(stringFiles[0]) mergedProjFile._path = newPath else: mergedProjFile = RCStrTblFile(newPath) for stringfile in stringFiles: ScanStringTableFile(stringfile, headers) mergedProjFile = RCStrTblFile.merge(newPath, mergedProjFile, stringfile, True, True) return mergedProjFile