8 Skip = ['\n', '\t', ' ']
9 Special = ["(", "\"", ":", ",", "{", "}", ")", "/", "*"]
35 def ExtractMethods(F, inputMethodsFile, appName):
38 while (Temp != "EOF"):
39 #Extract the input methods
42 Temp = GetToken(F) #",(,input
43 #input "","",linkedHashMap
45 while (Temp!="input" and Temp!="}"):
48 inputMethod += ",\""+appName+"\""
54 inputMethod += ",\""+appName+"\")"
56 elif (Temp == "input"):
57 while (Temp!="input" and Temp!="}"):
60 inputMethod += ",\""+appName+"\""
64 if (GetToken(F) != "="): #We have a function to create object for
65 if (appName == "App1"):
66 extractedFunctionsApp1.write("//Global Object for functions in subscribe method!\n")
67 extractedFunctionsApp1.write("def %s = this.&" % NameofFunc)
68 extractedFunctionsApp1.write("%s\n" % NameofFunc)
70 extractedFunctionsApp2.write("//Global Object for functions in subscribe method!\n")
71 extractedFunctionsApp2.write("def %s = this.&" % NameofFunc)
72 extractedFunctionsApp2.write("%s\n" % NameofFunc)
75 if (inputMethod != ""):
76 inputMethodsFile.write(inputMethod+"\n")
81 #Extract the methods from App1 and store in inputMethodsFile
82 F1 = open("Extractor/App1/App1.groovy", "r")
83 inputMethodsFile1 = open("Extractor/App1/inputMethodsFile1.groovy", "w+")
84 extractedFunctionsApp1 = open("Extractor/App1/extractedFunctionsApp1.groovy", "w+")
85 ExtractMethods(F1, inputMethodsFile1, "App1")
86 inputMethodsFile1.close()
89 #Extract the methods from App2 and store in inputMethodsFile
90 F2 = open("Extractor/App2/App2.groovy", "r")
91 inputMethodsFile2 = open("Extractor/App2/inputMethodsFile2.groovy", "w+")
92 extractedFunctionsApp2 = open("Extractor/App2/extractedFunctionsApp2.groovy", "w+")
93 ExtractMethods(F2, inputMethodsFile2, "App2")
94 inputMethodsFile2.close()
98 #Save the extracted methods and methods functions in a same file
99 extractorFile = open("Extractor/extractorFile.groovy", "w+")
100 inputMethodsFile1 = open("Extractor/App1/inputMethodsFile1.groovy", "r")
101 inputMethodsFile2 = open("Extractor/App2/inputMethodsFile2.groovy", "r")
102 inputMethods = open("Extractor/inputMethods.groovy", "r")
103 for line in inputMethods:
104 extractorFile.write(line)
105 extractorFile.write("\n\n")
106 for line in inputMethodsFile1:
107 extractorFile.write(line)
108 for line in inputMethodsFile2:
109 extractorFile.write(line)
110 extractorFile.close()
111 inputMethodsFile1.close()
112 inputMethodsFile2.close()
116 #Run the file to extract the objects
117 os.system("groovy Extractor/extractorFile.groovy")