def run_parser(self, hide_attributes, hide_methods): if len(self.controller.files) > 0: processor = model.FileProcessor(self.controller.statistics) processor.process_files(self.controller.files) self.controller.extracted_modules = processor.get_modules() new_uml = uml_out.MakeUML(hide_attributes, hide_methods) return new_uml.create_class_diagram(self.controller.extracted_modules) else: print("Error: No files were set, use command change_python_files")
def run_parser(self, hide_attributes, hide_methods): if len(self.files) == 0: return False if self.filer.process_files(self.files) == 0: return False for module in self.filer.get_modules(): self.parser.process_module(module) new_uml = uml_out.MakeUML(hide_attributes, hide_methods) return new_uml.create_class_diagram(self.parser.get_modules())
def do_load_csv_for_uml(self, params): ''' Loads csv file and creates UML diagram [command line] [file.csv] Author: Peter ''' if params == '': params = 'output.csv' args = params.split(' ') print(args) if len(args) >= 1: input_file = args[0] if input_file.endswith('.csv'): csvloader = csv.CSV_handler() module = csvloader.open_file(input_file) makediagram = uml_out.MakeUML(True, True) if makediagram.create_class_diagram(module): print("{} successfully converted to UML class diagram".format( input_file))
def test_run_parser_multi(self): """ Location: 'model.py-FileProcessor-process_class-Lines(126-170)' Testing whether the processed module can be used to create a uml diagram with multiple files Author: Jake """ statistics = StatisticsCreator("RefactorTestDB") statistics.create_tables() processor = model.FileProcessor(statistics) processor.process_files(self.multi_file_test) extracted_modules = processor.get_modules() new_uml = uml_out.MakeUML(False, False) expected = new_uml.create_class_diagram(extracted_modules) controller = Controller() controller.files = self.multi_file_test actual = controller.run_parser(False, False) self.assertEqual(expected, actual)
return True except IOError: print("Cannot write csv file. Try again another day") return False except BaseException: print( 'The system encountered a problem here. Please turn off your computer,' ) print( 'jump up and down three times, flap your arms and quack like a duck and then try again.' ) return False if __name__ == '__main__': csvhandler = CSVHandler() newmodule = csvhandler.open_file('plants.csv') # print(newmodule) # print('------------------------------') # doParse = model.FileProcessor() # filenames =["plants.py"] # outfile = filenames[0].replace('.py', '.csv') # doParse.process_files(filenames) # modules = doParse.get_modules() # print(modules) # csvhandler.write_csv_file(modules, outfile) # csvhandler.write_csv_file(newmodule, 'myclass.csv') makediagram = uml.MakeUML(True, True) # makediagram.create_class_diagram(newmodule)