__init__.py 1.47 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 12 13 14
from MDANSE import PLATFORM, REGISTRY
from MDANSE.GUI.Plugins.DataPlugin import DataPlugin 
from MDANSE.GUI.Plugins.JobPlugin import JobPlugin

15 16 17
from MDANSE.GUI.Handlers import *
from MDANSE.GUI.Plugins import *
from MDANSE.GUI.Widgets import *
18

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

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

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

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

39
    if not hasattr(data, "_type"):
40
        continue
41

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