From cb69d2e1c7ced951cbf7a31ee286b0ed92cab8a8 Mon Sep 17 00:00:00 2001 From: rcoh Date: Fri, 18 Feb 2011 16:56:43 -0500 Subject: Adding Epydoc generated docs. --- html/SmootLight.util.ComponentRegistry-pysrc.html | 303 ++++++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 html/SmootLight.util.ComponentRegistry-pysrc.html (limited to 'html/SmootLight.util.ComponentRegistry-pysrc.html') diff --git a/html/SmootLight.util.ComponentRegistry-pysrc.html b/html/SmootLight.util.ComponentRegistry-pysrc.html new file mode 100644 index 0000000..bce3a68 --- /dev/null +++ b/html/SmootLight.util.ComponentRegistry-pysrc.html @@ -0,0 +1,303 @@ + + + + + SmootLight.util.ComponentRegistry + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Package SmootLight :: + Package util :: + Module ComponentRegistry + + + + + + +
[hide private]
[frames] | no frames]
+
+

Source Code for Module SmootLight.util.ComponentRegistry

+
+ 1  import hashlib  
+ 2  from logger import main_log 
+ 3  import thread 
+ 4  #TODO: make component registry a singleton 
+
5 -def initRegistry(): +
6 #TODO: don't overwrite existing registry + 7 if not 'Registry' in globals(): + 8 globals()['Registry'] = {} + 9 makelock() +
10 +11 +
12 -def makelock(): +
13 global utilLock +14 utilLock = thread.allocate_lock() +
15 -def clearRegistry(): +
17 +
18 -def removeComponent(cid): +
19 global Registry +20 Registry.pop(cid) +
21 +
22 -def getLock(): +
23 global utilLock +24 return utilLock +
25 -def getComponent(cid): +
26 global Registry +27 return Registry[cid] +
28 +29 #Registry of all components of the light system +30 #TODO: pick a graceful failure behavior and implement it +
31 -def registerComponent(component, cid=None): +
32 global Registry +33 if cid != None: +34 Registry[cid] = component +35 else: +36 try: +37 cid = component['Id'] +38 except KeyError: +39 cid = getNewId() +40 component['Id'] = cid +41 main_log.debug(cid + 'automatically assigned') +42 if cid in Registry: +43 main_log.warn(cid + 'overwritten.') +44 Registry[cid] = component +45 return cid +
46 +
47 -def verifyUniqueId(cid): +
48 global Registry +49 return not cid in Registry +
50 +
51 -def removeComponent(cid): +
52 global Registry +53 Registry.pop(cid) +
54 +
55 -def getNewId(): +
56 global Registry +57 trialKey = len(Registry) +58 trialId = hashlib.md5(str(trialKey)).hexdigest() +59 while trialId in Registry: +60 trialKey += 1 +61 trialId = hashlib.md5(str(trialKey)).hexdigest() +62 return trialId +
63 +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + -- cgit v1.2.3