__init__.py 1.41 KB
Newer Older
1
import glob
2 3 4
import os
import platform

5
from MDANSE.Externals.pubsub import pub as PUBLISHER
6

7 8 9 10
# Hack for the (in)famous "(python:865): LIBDBUSMENU-GLIB-WARNING **: Trying to remove a child that doesn't believe we're it's parent."
if platform.dist()[0].lower() == "ubuntu":
    os.environ["UBUNTU_MENUPROXY"] = "0" 
        
11
from MDANSE import REGISTRY
12 13 14
from MDANSE.GUI.Plugins.DataPlugin import DataPlugin 
from MDANSE.GUI.Plugins.JobPlugin import JobPlugin

15 16 17
REGISTRY.update(os.path.join(os.path.dirname(__file__),"Handlers"))
REGISTRY.update(os.path.join(os.path.dirname(__file__),"Plugins"))
REGISTRY.update(os.path.join(os.path.dirname(__file__),"Widgets"))
18 19 20

for job in REGISTRY["job"].values():

21
    if not hasattr(job, "_type"):
22
        continue
23
                    
24
    attrs = {"_type"     : job._type,
25 26
             "ancestor"  : getattr(job,'ancestor',job.ancestor),
             "category"  : getattr(job, "category", ("Miscellaneous",)),
27
             "label"     : getattr(job, "label", job.__name__)}
28

29
    kls = type("%sPlugin" % job.__name__, (JobPlugin,), attrs)
30
    REGISTRY[job._type] = kls
31 32

for data in REGISTRY["input_data"].values():
33

34
    if not hasattr(data, "_type"):
35
        continue
36

37
    attrs = {"_type"    : data._type, 
38
             "label"    : " ".join("".split("_")).capitalize(),
39
             "ancestor" : ['empty_data']}
40 41
    kls = type("%sPlugin" % data.__name__, (DataPlugin,), attrs)
    REGISTRY[data._type] = kls