Exemplo n.º 1
0
 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()  
Exemplo n.º 2
0
 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 None:
         file = RCDialogFile( path )
         if not file.load():
             raise Exception("Could not load Dialog File: %s"%path)
     else: file = obj
     self._projs[projName] = copy.deepcopy(file._dialogs)
     return True
Exemplo n.º 3
0
def ScanAndMergeDialogs(newPath, dialogFiles): 
    """Scans all files in a list and merges them together to make a project
    level file. This is considered a merge since its RCDialogFiles that are 
    being utilized. If there is a problem scanning, then the error is raised.
    """
    if len(dialogFiles) < 1: return None
    from lslib.base.file.utility.DialogFile import ScanDialogFile, RCDialogFile
    
    # find headers for this particular resource
    headers = _getHeadersFromPath( dialogFiles[0]._path )
    
    # scan all files with the headers, merging as we go.
    if len(dialogFiles) == 1:
        mergedProjFile = copy.deepcopy(dialogFiles[0])
        mergedProjFile._path = newPath
    else:
        mergedProjFile = RCDialogFile(newPath)    
        for dialogfile in dialogFiles: 
            ScanDialogFile(dialogfile, headers)
            mergedProjFile = RCDialogFile.merge(newPath, mergedProjFile, dialogfile, True, True)
    return mergedProjFile