File indexing completed on 2024-04-06 12:12:53
0001 import os
0002 from os.path import sep, join
0003 import importlib
0004
0005 class _ModuleProxy (object):
0006 def __init__(self, package, name):
0007 self._package = package
0008 self._name = name
0009 self._caller = None
0010 def __call__(self,**kwargs):
0011 if not self._caller:
0012 self._caller = getattr(importlib.import_module(self._package+'.'+self._name),self._name)
0013 return self._caller(**kwargs)
0014
0015
0016 def _setupProxies(fullName:str):
0017 _cmssw_package_name='.'.join(fullName.split(sep)[-3:-1])
0018 basename = fullName.split(sep)[-1]
0019 pathname = fullName[:-1*len(basename)]
0020 proxies = dict()
0021 for filename in ( x for x in os.listdir(pathname) if (len(x) > 3 and x[-3:] == '.py' and x != basename and ((len(x) < 6) or (x[-6:] != 'cfi.py')))):
0022 name = filename[:-3]
0023 proxies[name] = _ModuleProxy(_cmssw_package_name, name)
0024 return proxies