7 Skip = ["(", "\"", ":", ",", "{", "}", ")", '\n', '\t', ' ', "/"]
17 if (c == "{" or c == "}"):
25 if (c == "{" or c == "}"):
39 F = open("Extractor/App.groovy", "r")
40 Out = open("Extractor/extractedObjects.groovy", "w+")
47 while (Temp != "EOF"):
48 #Extract the global objects for input
52 Temp = GetToken(F) #name or "name"
53 #input name: "name", type: "type",...
55 Temp = GetToken(F) #"name"
58 Temp = GetToken(F) #"type"
60 #input "name", "type",...
63 Temp = GetToken(F) #"type"
69 while (Temp != "input" and Temp != "}"):
73 elif (Temp == "required"):
76 elif (Temp == "multiple"):
80 if (Type == "capability.lock"):
82 print(Object+", "+Title)
83 if (Multiple != "" and Multiple == "true"):
84 g = raw_input("Enter the number of locks to control: (1, 2, or 3)\n")
85 Out.write("//Global Object for class lock!\n")
86 Out.write("@Field def %s = new Locking(sendEvent, " % Object)
87 Out.write("%s)\n" % g)
88 elif (Multiple == "" or Multiple == "false"):
89 Out.write("//Global Object for class lock!\n")
90 Out.write("@Field def %s = new Locking(sendEvent, 1)\n" % Object)
91 #elif (Type == "capability.alarm"):
93 #elif (Type == "capability.battery"):
95 #elif (Type == "capability.beacon"):
97 #elif (Type == "capability.carbonMonoxideDetector"):
99 #elif (Type == "capability.colorControl"):
101 elif (Type == "capability.contactSensor"):
103 print(Object+", "+Title)
104 if (Multiple != "" and Multiple == "true"):
105 g = raw_input("Enter the number of contactSensors to monitor: (1, 2, or 3)\n")
106 Out.write("//Global Object for class contactSensor!\n")
107 Out.write("@Field def %s = new Contacting(sendEvent, " % Object)
108 Out.write("%s)\n" % g)
109 elif (Multiple == "" or Multiple == "false"):
110 Out.write("//Global Object for class contactSensor!\n")
111 Out.write("@Field def %s = new Contacting(sendEvent, 1)\n" % Object)
112 #elif (Type == "capability.doorControl"):
114 #elif (Type == "capability.energyMeter"):
116 #elif (Type == "capability.illuminanceMeasurement"):
118 #elif (Type == "capability.accelerationSensor"):
120 #elif (Type == "capability.motionSensor"):
122 #elif (Type == "capability.musicPlayer"):
124 #elif (Type == "capability.powerMeter"):
126 #elif (Type == "capability.presenceSensor"):
128 #elif (Type == "capability.relativeHumidityMeasurement"):
130 #elif (Type == "capability.relaySwitch"):
132 #elif (Type == "capability.sleepSensor"):
134 #elif (Type == "capability.smokeDetector"):
136 #elif (Type == "capability.stepSensor"):
138 elif (Type == "capability.switch"):
140 print(Object+", "+Title)
141 if (Multiple != "" and Multiple == "true"):
142 g = raw_input("Enter the number of switches to control: (1, 2, or 3)\n")
143 Out.write("//Global Object for class switch!\n")
144 Out.write("@Field def %s = new Switching(sendEvent, " % Object)
145 Out.write("%s)\n" % g)
146 elif (Multiple == "" or Multiple == "false"):
147 Out.write("//Global Object for class switch!\n")
148 Out.write("@Field def %s = new Switching(sendEvent, 1)\n" % Object)
149 #elif (Type == "capability.switchLevel"):
151 #elif (Type == "capability.temperatureMeasurement"):
153 #elif (Type == "capability.thermostat"):
155 #elif (Type == "capability.valve"):
157 #elif (Type == "capability.waterSensor"):
159 #elif (Type == "capability.touchSensor"):
161 #elif (Type == "capability.imageCapture"):
163 #elif (Type == "device.mobilePresence"):
165 #elif (Type == "device.aeonKeyFob"):
167 elif (Type == "mode"):
169 print(Object+", "+Title)
170 g = raw_input("Enter the mode: ")
171 Out.write("//Global variable for mode!\n")
172 Out.write("@Field def %s = " % Object)
173 Out.write("\"%s\"\n" % g)
174 #elif (Type == "decimal"):
176 #elif (Type == "text"):
178 elif (Type == "number"):
180 print(Object+", "+Title)
181 g = raw_input("Enter the number: ")
182 Out.write("//Global variable for number!\n")
183 Out.write("@Field def %s = " % Object)
184 Out.write("%s\n" % g)
185 #elif (Type == "time"):
187 #elif (Type == "enum"):
189 #elif (Type == "bool"):
191 elif (Type == "phone"):
193 print(Object+", "+Title)
194 g = raw_input("Enter the number to send notification to:\n")
195 Out.write("//Global variable for phone number!\n")
196 Out.write("@Field def %s = " % Object)
197 Out.write("%s\n" % g)
198 elif (Type == "contact"):
200 print(Object+", "+Title)
201 g = raw_input("Enter the name of the recipients:\n")
202 Out.write("//Global variable for recipients!\n")
204 Out.write("@Field def %s = " % Object)
205 Out.write("%s\n" % g)
206 #Extract the global object for functions
207 elif (Temp == "def"):
210 if (GetToken(F) != "="): #We have a function to create object for
211 Out.write("//Global Object for functions in subscribe method!\n")
212 Out.write("@Field def %s = this.&" % NameofFunc)
213 Out.write("%s\n" % NameofFunc)
214 if (Temp != "input"):