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

5
from MDANSE.Externals.pubsub.pub import Publisher
6 7 8

PUBLISHER = Publisher()

9 10 11 12
# 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" 
        
13 14 15 16
from MDANSE import PLATFORM, REGISTRY
from MDANSE.GUI.Plugins.DataPlugin import DataPlugin 
from MDANSE.GUI.Plugins.JobPlugin import JobPlugin

17 18 19
from MDANSE.GUI.Handlers import *
from MDANSE.GUI.Plugins import *
from MDANSE.GUI.Widgets import *
20

21 22 23 24
macrosDirectories = sorted([x[0] for x in os.walk(PLATFORM.macros_directory())][0:])
 
for d in macrosDirectories:
    REGISTRY.update(d)
25 26 27

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

28
    if not hasattr(job, "_type"):
29
        continue
30
                    
31
    attrs = {"_type"     : job._type,
32 33
             "ancestor"  : getattr(job,'ancestor',job.ancestor),
             "category"  : getattr(job, "category", ("Miscellaneous",)),
34 35 36
             "label"     : getattr(job, "label", job.__name__)}
            
    kls = type("%sPlugin" % job.__name__, (JobPlugin,), attrs)
37
    REGISTRY[job._type] = kls
38 39

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

41
    if not hasattr(data, "_type"):
42
        continue
43

44
    attrs = {"_type"    : data._type, 
45
             "label"    : " ".join("".split("_")).capitalize(),
46
             "ancestor" : ['empty_data']}
47 48
    kls = type("%sPlugin" % data.__name__, (DataPlugin,), attrs)
    REGISTRY[data._type] = kls