Adding presence.present event.
[smartthings-infrastructure.git] / Extractor / ExtractorScript.py
index c96daa7..c37c2b8 100644 (file)
@@ -87,16 +87,11 @@ def ExtractFunctions(F, appName):
                        while (Temp != "\"" and Temp != "app" and Temp != "location"):
                                Temp = GetToken(F)
                        if Temp == "\"":
-                               Temp = GetToken(F)
-                       #print "DEBUG: %s" % variable
-                       #print capabilityMap
-                       #print eventList
-                       #if variable == "app" or variable == "location":
-                               
+                               Temp = GetToken(F)              
                        if Temp == "app" or Temp == "location":
                                if Temp not in eventList:
                                        eventList.append(Temp)
-                       elif variable in capabilityMap.keys() and capabilityMap[variable] not in capabilityList:
+                       elif Temp not in eventList or (variable in capabilityMap.keys() and capabilityMap[variable] not in capabilityList):
                                # We do not repeat the same capability twice
                                capability = capabilityMap[variable]
                                capabilityList.append(capability)
@@ -106,7 +101,10 @@ def ExtractFunctions(F, appName):
                                        listOfEvents.append(variable)
                                else:
                                        eventVarMap[Temp] = [variable]
-                                       
+                       #print "DEBUG: %s - %s" % (variable, Temp)
+                       #print capabilityMap
+                       #print eventList
+
                #Check and analyze capabilities for physical interaction
                AnalyzeCapabilities(Temp, appName, F)
 
@@ -116,7 +114,6 @@ def ExtractFunctions(F, appName):
        AnalyzePhysicalInteraction(app1Capabilities, app2Capabilities)
        AnalyzePhysicalInteraction(app2Capabilities, app1Capabilities)
 
-
 def AnalyzeCapabilities(Temp, appName, F):
                        #Illuminance related
        if (Temp == "capability.switch" or
@@ -274,13 +271,11 @@ def ExtractEvents(extractedEvents):
                        for line in event:
                                extractedEvents.write("\t\t" + line)
                        event.close()
-                       if capability == "capability.presenceSensor":
-                               extractedEvents.write("\t\t\t} else {\n")
-                               event = open("eventSimulator/presencePresencePresentEvent.groovy", "r")
-                               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:
+                               extractedEvents.write("\t\t" + line)
+                       event.close()
                elif eventList[i] == "doorState":
                        #Write two events subsequently
                        extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")