def _fallback_getattr(self, name): # Try: # - in the global namespace # - in the ROOT namespace # - in gROOT (ROOT lists such as list of files, # memory mapped files, functions, geometries ecc.) # The first two attempts allow to lookup # e.g. ROOT.ROOT.Math as ROOT.Math if name == '__all__': self._handle_import_all() # Make the attributes of the facade be injected in the # caller module raise AttributeError() # Note that hasattr caches the lookup for getattr elif hasattr(gbl_namespace, name): return getattr(gbl_namespace, name) elif hasattr(gbl_namespace.ROOT, name): return getattr(gbl_namespace.ROOT, name) else: res = gROOT.FindObject(name) if res: return res raise AttributeError( "Failed to get attribute {} from ROOT".format(name))
def _fallback_getattr(self, name): # Try: # - in the global namespace # - in the ROOT namespace # - in gROOT (ROOT lists such as list of files, # memory mapped files, functions, geometries ecc.) # The first two attempts allow to lookup # e.g. ROOT.ROOT.Math as ROOT.Math if name == '__all__': self._handle_import_all() # Make the attributes of the facade be injected in the # caller module raise AttributeError() try: return getattr(gbl_namespace, name) except AttributeError as err: try: return getattr(gbl_namespace.ROOT, name) except AttributeError: res = gROOT.FindObject(name) if res: return res else: raise AttributeError(str(err))