diff options
| author | Thomas Kluyver <takowl@gmail.com> | 2013-01-13 08:14:04 -0800 |
|---|---|---|
| committer | Thomas Kluyver <takowl@gmail.com> | 2013-01-13 08:14:04 -0800 |
| commit | 57cccc9d6a0af98b86024a6d6d054997c8ba509f (patch) | |
| tree | 6e3f122bf8b5b8b156a3316eb10a7f647e449fdc /weatbag/items/__init__.py | |
| parent | d327e21c9c8fec8dea82035e87bfd1a3ba2b813c (diff) | |
| parent | 727343ffdc825be9e7981a57cf592594f358da94 (diff) | |
Merge pull request #11 from takluyver/items-framework
Items framework
Diffstat (limited to 'weatbag/items/__init__.py')
| -rw-r--r-- | weatbag/items/__init__.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/weatbag/items/__init__.py b/weatbag/items/__init__.py new file mode 100644 index 0000000..3d0922f --- /dev/null +++ b/weatbag/items/__init__.py @@ -0,0 +1,26 @@ +from importlib import import_module +from types import ModuleType + +def get_item_module(name): + """Returns the module for that item, or a blank module if no module exists. + """ + name = name.replace(' ','_') + try: + return import_module('weatbag.items.' + name) + except ImportError: + return ModuleType(name, "Dummy Module") + + +def _combine(item1, item2): + "Try combining items one way" + try: + return get_item_module(item1).combine(item2) + except AttributeError: + pass + +def combine(item1, item2): + "Try combining items either way round." + results = _combine(item1, item2) + if results is None: + results = _combine(item2, item1) + return results |
