summaryrefslogtreecommitdiff
path: root/detectors
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2011-08-04 11:38:27 -0400
committerStan Seibert <stan@mtrr.org>2011-08-04 11:38:27 -0400
commit125de2738868d30c537d84b471cfb5e8274fe6d8 (patch)
tree199adf5b9663fecc7356851238dd33b93d16f0ca /detectors
parentd9982308f364abf082010c5db2c4b893f17f7bf6 (diff)
downloadchroma-125de2738868d30c537d84b471cfb5e8274fe6d8.tar.gz
chroma-125de2738868d30c537d84b471cfb5e8274fe6d8.tar.bz2
chroma-125de2738868d30c537d84b471cfb5e8274fe6d8.zip
Add method to detectors module to locate a detector build function
using the same string decorators as in camera and view.
Diffstat (limited to 'detectors')
-rw-r--r--detectors/__init__.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/detectors/__init__.py b/detectors/__init__.py
index d7583a6..043bdbd 100644
--- a/detectors/__init__.py
+++ b/detectors/__init__.py
@@ -3,6 +3,7 @@ from sno import build_sno as build_sno_detector
import os
import sys
+import inspect
dir = os.path.split(os.path.realpath(__file__))[0]
sys.path.append(dir + '/..')
@@ -35,3 +36,15 @@ def build_sno():
@buildable('real_sno')
def build_real_sno():
return build_sno_detector(real_av=True)
+
+
+def find(detector_name):
+ members = globals()
+ buildable_lookup = {}
+ for member in members.values():
+ if inspect.isfunction(member) and \
+ hasattr(member, 'buildable') and member.buildable == True:
+ buildable_lookup[member.identifier] = member
+
+ if detector_name in buildable_lookup:
+ return buildable_lookup[detector_name]()