Beispiel #1
0
    def _handle_import_all(self):
        # Called if "from ROOT import *" is executed in the app.
        # Customises lookup in Python's main module to also
        # check in C++'s global namespace

        if sys.hexversion >= 0x3000000:
            raise ImportError(
                '"from ROOT import *" is not supported in Python 3')
        if self._is_ipython:
            import warnings
            warnings.warn('"from ROOT import *" is not supported in IPython')
            # Continue anyway, just in case it works

        # Get caller module (jump over the facade)
        caller = sys.modules[sys._getframe(2).f_globals['__name__']]

        # Inject some predefined attributes of the facade
        for name in self._cppyy_exports + ['gROOT', 'AddressOf']:
            caller.__dict__[name] = getattr(self, name)

        # Install the hook
        cppyy_backend._set_cpp_lazy_lookup(caller.__dict__)

        # Return empty list to prevent further copying
        return self.module.__all__
Beispiel #2
0
    def _handle_import_all(self):
        # Called if "from ROOT import *" is executed in the app.
        # Customises lookup in Python's main module to also
        # check in C++'s global namespace

        # Get caller module (jump over the facade frames)
        num_frame = 2
        frame = sys._getframe(num_frame).f_globals['__name__']
        while frame == 'ROOT._facade':
            num_frame += 1
            frame = sys._getframe(num_frame).f_globals['__name__']
        caller = sys.modules[frame]

        # Install the hook
        cppyy_backend._set_cpp_lazy_lookup(caller.__dict__)
Beispiel #3
0
 def __getattr__(self, attr):
     if attr == '__all__':
         caller = sys.modules[sys._getframe(1).f_globals['__name__']]
         _backend._set_cpp_lazy_lookup(caller.__dict__)
     return []
Beispiel #4
0
 def __getattr__(self, attr):
     if attr == '__all__':
         caller = sys.modules[sys._getframe(1).f_globals['__name__']]
         _backend._set_cpp_lazy_lookup(caller.__dict__)
     return []