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

5 6 7 8
from wx.lib.pubsub.pub import Publisher

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 17 18 19 20 21 22 23 24
from MDANSE import PLATFORM, REGISTRY
from MDANSE.GUI.Plugins.DataPlugin import DataPlugin 
from MDANSE.GUI.Plugins.JobPlugin import JobPlugin

directories = sorted([x[0] for x in os.walk(os.path.dirname(__file__))][1:])

macrosDir = PLATFORM.macros_directory()
directories.insert(0,macrosDir)
directories.extend(sorted([x[0] for x in os.walk(macrosDir)][1:]))

for d in directories:
    REGISTRY.update_registry(d)
25 26 27 28 29

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

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

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

40 41
    if not hasattr(data, "type"):
        continue
42

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