Fixing a bug: missing a closing parenthesis.
[smartthings-infrastructure.git] / Extractor / ExtractorScript.py
index 4bc7306..3567349 100644 (file)
@@ -89,8 +89,8 @@ def ExtractFunctions(F, appName):
                        if Temp == "\"":
                                Temp = GetToken(F)              
 
-                       print "DEBUG: %s - %s" % (variable, Temp)
-                       print capabilityMap
+                       #print "DEBUG: %s - %s" % (variable, Temp)
+                       #print capabilityMap
                        if Temp == "app" or Temp == "location":
                                if Temp not in eventList:
                                        eventList.append(Temp)
@@ -298,6 +298,7 @@ def ExtractEvents(extractedEvents):
                        for line in event:
                                extractedEvents.write("\t\t" + line)
                        event.close()
+                       extractedEvents.write("\t\t\t}\n")
                elif eventList[i] == "presence.present": #Case for Touched event
                        event = open("eventSimulator/presencePresencePresentEvent.groovy", "r")
                        for line in event:
@@ -413,6 +414,15 @@ def ExtractEvents(extractedEvents):
                        event.close()
                        extractedEvents.write("\t\t\t}\n")
                elif eventList[i] == "carbonMonoxide.clear":
+                       #Check which capability
+                       variable = eventVarMap[eventList[i]]
+                       if eventList[i] not in eventVarCounterMap.keys():
+                               eventVarCounterMap[eventList[i]] = 1
+                               eventVarCount = 0
+                       else:
+                               eventVarCount = eventVarCounterMap[eventList[i]]
+                               eventVarCounterMap[eventList[i]] = eventVarCount + 1
+                       capability = capabilityMap[variable[eventVarCount]]
                        if capability == "capability.smokeDetector":
                                event = open("eventSimulator/smokeCarbonMonoxideDefaultClearEvent.groovy", "r")
                        elif capability == "capability.carbonMonoxideDetector":
@@ -421,6 +431,15 @@ def ExtractEvents(extractedEvents):
                                extractedEvents.write("\t\t" + line)
                        event.close()
                elif eventList[i] == "carbonMonoxide.detected":
+                       #Check which capability
+                       variable = eventVarMap[eventList[i]]
+                       if eventList[i] not in eventVarCounterMap.keys():
+                               eventVarCounterMap[eventList[i]] = 1
+                               eventVarCount = 0
+                       else:
+                               eventVarCount = eventVarCounterMap[eventList[i]]
+                               eventVarCounterMap[eventList[i]] = eventVarCount + 1
+                       capability = capabilityMap[variable[eventVarCount]]
                        if capability == "capability.smokeDetector":
                                event = open("eventSimulator/smokeCarbonMonoxideDefaultDetectedEvent.groovy", "r")
                        elif capability == "capability.carbonMonoxideDetector":
@@ -429,6 +448,15 @@ def ExtractEvents(extractedEvents):
                                extractedEvents.write("\t\t" + line)
                        event.close()
                elif eventList[i] == "carbonMonoxide.tested":
+                       #Check which capability
+                       variable = eventVarMap[eventList[i]]
+                       if eventList[i] not in eventVarCounterMap.keys():
+                               eventVarCounterMap[eventList[i]] = 1
+                               eventVarCount = 0
+                       else:
+                               eventVarCount = eventVarCounterMap[eventList[i]]
+                               eventVarCounterMap[eventList[i]] = eventVarCount + 1
+                       capability = capabilityMap[variable[eventVarCount]]
                        if capability == "capability.smokeDetector":
                                event = open("eventSimulator/smokeCarbonMonoxideDefaultTestedEvent.groovy", "r")
                        elif capability == "capability.carbonMonoxideDetector":
@@ -850,7 +878,7 @@ def ExtractEvents(extractedEvents):
                        event.close()
                        
                ###TODO: Add more events later
-               extractedEvents.write("\t\t\tbreak\n")
+               extractedEvents.write("\n\t\t\tbreak\n")
        extractedEvents.write("\t}\n")
        extractedEvents.write("}\n")