def makeSysMenu( projMenuFiles, sysMenuPath, autosave=True ): """Passing in a list of paths to menu files, and a path for the new System level menu file, this function will join all of them into a new Master menu file for your entire solution. """ smf = SysMenuFile(sysMenuPath) for file in projMenuFiles: name = iohelp.lastdirname(file) try: smf.addProjLevelFile(name, file) except Exception as e: logging.exception(e) if autosave: smf.save() return smf
def __genSysLevelUtil( self, useExisting=False, useExistingLangLevel=False, keepInMem=False, save=True, doMenus=True, doDialogs=True, doStrings=True ): """Generate the System Level Utility files for an entire system. If `useExisting` has been set to True, it will use the existing project level utility files for generating the system level. Otherwise it will regenerate new project level files (ie, overwrite existing). If `keepInMem` is True, it wont overwrite existing files, instead it will generate the new files and keep them in memory for the system level creation and then discard them. """ if self.__changeoutputs: basename = opath.join(self.__outdir, Joiner.MASTER_FILENAME) else: basename = opath.join(self.__sysdir, Joiner.MASTER_FILENAME) sysMenus = SysMenuFile(basename+".menus") sysDialogs = SysDialogFile(basename+".dialogs") sysStrings = SysStrTblFile(basename+".strtbls") if not useExisting: for project, menuFile, dialogFile, stringFile in self.__genProjLevelUtil(useExistingLangLevel, keepInMem, True, useExisting, doMenus, doDialogs, doStrings): if doMenus: sysMenus.addProjLevelFile(project, '', obj=menuFile) if doDialogs: sysDialogs.addProjLevelFile(project, '', obj=dialogFile) if doStrings: sysStrings.addProjLevelFile(project, '', obj=stringFile) else: # iterate through # Since we can't generate new ones, we have to go look for them in subdirs. # Also since we are looking through the subdirs, we run the risk of pulling out # lang-level utility files. So we need to prune those too. for utils in iohelp.dirwalkl(self.__sysdir, exclude=iohelp.RCFilters.SysLevelFilter, filter=iohelp.RCFilters.UtilityFilter, ignore=iohelp.RCFilters.BinaryDirs): strFound, menuFound, dialogFound = False, False, False # we have all the util files for the project. for cpath,name in utils: project = iohelp.lastdirname( cpath ) # if file is lang-lvl, then skip it. if opath.splitext(name)[0] != project: logging.debug("thought was lang-lvl: %s,%s"%(project, opath.splitext(name)[0])) continue #TODO: not very elegant! plus is it true?? logging.debug("filter time: %s"%name) if iohelp.fileok(name, filter=iohelp.RCFilters.MenuFilter): menuFound = True if not doMenus: continue sysMenus.addProjLevelFile( project, cpath ) elif iohelp.fileok(name, filter=iohelp.RCFilters.DialogFilter): dialogFound = True if not doDialogs: continue sysDialogs.addProjLevelFile( project, cpath ) elif iohelp.fileok(name, filter=iohelp.RCFilters.StrTblFilter): strFound = True if not doStrings: continue sysStrings.addProjLevelFile(project, cpath ) else: logging.error("Matched utility filter when there was no need! %s"%cpath) if not (strFound and menuFound and dialogFound): logging.warning("Was unable to find all of %s's utility files."%project) if save: if doMenus: sysMenus.save() if doDialogs: sysDialogs.save() if doStrings: sysStrings.save() return sysMenus, sysDialogs, sysStrings