def orca_et_loader(uFile, parse, encoding=None,aReplacementVars={}): '''Custom Loader for ElementTree Include to add definition path to includes and to make make bulk include using placeholder possible ''' if uFile.endswith('*'): uRet=[] uFile2=ReplaceVars(uFile) uDir=AdjustPathToOs(os.path.dirname(uFile2)) uPattern=uFile2[len(uDir):] uPattern=uPattern[1:-1] aFiles=GetFileList(uDir) for uFile in aFiles: if uFile.startswith(uPattern): uLoadFile=AdjustPathToOs(uDir+u'/'+uFile) uLoadFileRedirect=oORCA.oTheScreen.aSkinRedirects.get(uLoadFile) if uLoadFileRedirect: uLoadFile=AdjustPathToOs(ReplaceVars(uLoadFileRedirect)) Logger.debug (u'XML: Bulk-Loading XML Include:'+uLoadFile) uRaw= ElementInclude.default_loader(uLoadFile, "text", encoding) uRaw2 = ReplaceDefVars(uRaw,aReplacementVars) uRet.append(fromstring(uRaw2)) #uRet.append(ElementInclude.default_loader(uLoadFile, parse, encoding)) if len(uRet)==0: return None else: return uRet else: uFile2=uFile if FileExists(uFile2): Logger.debug (u'XML: Loading XML Include:'+uFile2) uRaw= ElementInclude.default_loader(uFile2, "text", encoding) uRaw2 = ReplaceDefVars(uRaw,aReplacementVars) bRet = fromstring(uRaw2) #bRet= ElementInclude.default_loader(uFile2, parse, encoding) else: Logger.warning (u'XML: Skipping XML Include (File not found):'+uFile2) bRet=None return bRet
def _loader(self, href, parse, encoding=None): return ElementInclude.default_loader(self._path_map[href], parse, encoding)
def __call__(self, href, typ, encoding=None): """Fix relative references and call the default loader.""" return ElementInclude.default_loader(join(self.base, href), typ, encoding)
def __wrapped(href: str, parse, encoding=None): abshref = base / href return ElementInclude.default_loader(str(abshref), parse, encoding)