def grep(options): """ Main function """ if Grep.evaluate_input(options): grep_obj = Grep(options) grep_obj.process_file(options[1]) if "n" in options[1]: print("Numar de aparitii: {0}".format(grep_obj.counter)) else: config.help_function(NAME, OPTIONS)
L= os.sys.argv[3] TEST= os.sys.argv[4] if(DR[-1] == "/"): DR = DR[:-1] if(DT[-1] == "/"): DT = DT[:-1] if(L[-1] == "/"): L = L[:-1] if(TEST[-1] == "/"): TEST = TEST[:-1] method = "Grep" print method shutil.rmtree("cleanData/", True) grep = Grep() grep.initalPreprocess(DR, DT, L, TEST) grep.testDirToOutput("cleanData/TEST/", "cleanData/" ) with open("cleanData/output.txt") as methodOutput: for line in methodOutput.read().split(): finalOutput.write(method + "," + line + "\n") method = "SuperGrep" print method shutil.rmtree("cleanData/", True) grep = Grep(True) grep.initalPreprocess(DR, DT, L, TEST) grep.testDirToOutput("cleanData/TEST/", "cleanData/" ) with open("cleanData/output.txt") as methodOutput: for line in methodOutput.read().split(): finalOutput.write(method + "," + line + "\n")
def test_grep(self): self.job = Grep().run(input=[chekhov], params='d.*?co') self.assertEquals(len(list(self.results(self.job))), 17)