From a6e312c9f0e1bd690963191bb5331eaabb06b431 Mon Sep 17 00:00:00 2001 From: Simon Poirier Date: Sat, 24 Oct 2009 21:18:52 +0000 Subject: creator with viewer and non-linear editing. Conflicts: tutorius/creator.py --- (limited to 'tutorius/addon.py') diff --git a/tutorius/addon.py b/tutorius/addon.py index 15612c8..7ac68f7 100644 --- a/tutorius/addon.py +++ b/tutorius/addon.py @@ -38,6 +38,9 @@ import logging PREFIX = __name__+"s" PATH = re.sub("addon\\.py[c]$", "", __file__)+"addons" +TYPE_ACTION = 'action' +TYPE_EVENT = 'event' + _cache = None def _reload_addons(): @@ -47,9 +50,11 @@ def _reload_addons(): mod = __import__(PREFIX+'.'+re.sub("\\.py$", "", addon), {}, {}, [""]) if hasattr(mod, "__action__"): _cache[mod.__action__['name']] = mod.__action__ + mod.__action__['type'] = TYPE_ACTION continue if hasattr(mod, "__event__"): _cache[mod.__event__['name']] = mod.__event__ + mod.__event__['type'] = TYPE_EVENT def create(name, *args, **kwargs): global _cache @@ -78,4 +83,13 @@ def get_addon_meta(name): _reload_addons() return _cache[name] +def get_name_from_type(typ): + global _cache + if not _cache: + _reload_addons() + for addon in _cache.keys(): + if typ == _cache[addon]['class']: + return addon + return None + # vim:set ts=4 sts=4 sw=4 et: -- cgit v0.9.1