コード例 #1
0
ファイル: push.py プロジェクト: RailComm/LiVSs
 def __m2r(self): 
     logging.debug("Pushing menus into resources...")
     if isSystemLevelMenu(self.__input):
         logging.debug("\tMenus file is System Level.")
         file = SysMenuFile( 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
             logging.debug("\t\tUpdating %s @> %s"%(name,cpath))
             resource.updateMenus(projFile)
             
     else:
         logging.debug("\tMenus file is Project or language Level.")
         projFile = RCMenuFile( 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.updateMenus(projFile)
             else: raise MissingLangCodeError()  
コード例 #2
0
ファイル: SysMenuFile.py プロジェクト: RailComm/LiVSs
 def load(self, newpath=None): 
     if newpath is not None:
         if not isSystemLevelMenu( newpath ):
             raise TypeError("Path given is not a system level menu file.")
         else: self._path = newpath
     root = ET.parse(self._path).getroot()
     self._projs = {}
     projects = root.findall("PROJECT")
     for project in projects:
         try:
             menus = project.findall("MENU")
             lst = []
             for menu in menus:
                 m = RCMenu( menu.attrib["id"])
                 self.__fillNode( menu, None, m, 0 )
                 lst.append( m )
             self._projs[ project.attrib["name"] ] = lst
         except Exception as e: logging.warning( e )
     self.__loaded = True
     return True
コード例 #3
0
ファイル: SysMenuFile.py プロジェクト: RailComm/LiVSs
 def __init__(self, path):
     if not isSystemLevelMenu( path ):
         raise TypeError("Path given is not a system level menu file.")
     self._path = path
     self._projs = {} #map: "projname"-> [list of RCMenus]
     self.__loaded = False