File: _namespaces.py

package info (click to toggle)
gyoto 2.0.2-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,444 kB
  • sloc: cpp: 42,330; sh: 4,512; python: 3,436; xml: 2,865; makefile: 691; ansic: 346
file content (33 lines) | stat: -rw-r--r-- 978 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'''Namespace wrapper helpers

Not part of the API

'''

def make_namespace(Generic, _globals):
    import sys as _sys
    import inspect as _inspect
    from gyoto.core import requirePlugin as _requirePlugin, havePlugin as _havePlugin
    import gyoto.core as _core
    import gyoto.std as _std
    
    _modules = [_core, _std]
    
    _requirePlugin("lorene", True)
    if _havePlugin("lorene"):
        import gyoto.lorene as _lorene
        _modules.append(_lorene)
        
    res = []
    
    for _mod in _modules:
        for _name, _obj in _inspect.getmembers(_mod):
            if _inspect.isclass(_obj) and issubclass(_obj, Generic):
                __import__(_obj.__module__, globals(), locals(), [_obj.__name__,])
                _globals.update({_obj.__name__:
                                 getattr(_sys.modules[_obj.__module__], 
                                         _obj.__name__)})
                res . append(_obj.__name__)
    
    
    return res