Ejemplo n.º 1
0
    def validate_test_loader(cls, test_data):
        """if the data load correctly
        """
        cls.start = False
        cls.class_counter = 0
        cls.relationship_counter = 0
        cls.methods_counter = 0
        cls.attribute_counter = 0
        cls.class_braced = 0
        cls.end = False

        ErrorChecker.error_type(
            list, test_data,
            "VALIDATE TEST LOADER: data type is not corrected")
        try:
            for check_line in test_data:
                if '@startuml' == check_line:
                    cls.start = True
                elif 'class' in check_line:
                    cls.class_counter += 1
                elif '--' in check_line:
                    cls.relationship_counter += 1
                elif ':' in check_line:
                    cls.attribute_counter += 1
                elif '(' in check_line:
                    cls.methods_counter += 1
                elif '}' == check_line:
                    cls.class_braced += 1
                elif '@enduml' == check_line:
                    cls.end = True
        except Exception as e:
            print("ERROR: VALIDATE TEST LOADER CONTENT")
            print(e)
        finally:
            return cls.start and cls.end and cls.class_counter == cls.class_braced and cls.relationship_counter
Ejemplo n.º 2
0
 def set_over_string(self, overall_file):
     """This checks to see if there is a class dict
     """
     ErrorChecker.error_type(list, overall_file,
                             "SETUP OVER STRING: datatype not corrected")
     try:
         self.set_string(overall_file)
     except Exception as e:
         print("OVER STRING ERROR: This don'ts work ")
         print(e)
Ejemplo n.º 3
0
 def error_check_method(method_name):
     """this removes the String from the method attributes
     """
     ErrorChecker.error_type(
         str, method_name, "SETUP METHOD NAME: data type is not corrected")
     try:
         return Method.method_clean(method_name)
     except Exception as e:
         print("METHOD NAME ERROR: ")
         print(e)
Ejemplo n.º 4
0
 def error_check_attribute(attribute_name):
     """This changes String into the str or the diagram
     """
     ErrorChecker.error_type(str, attribute_name,
                             "ATTRIBUTE NAME: datatype not corrected ")
     try:
         return Attribute.attribute_clean(attribute_name)
     except Exception as e:
         print("ATTRIBUTE NAME ERROR: ")
         print(e)
Ejemplo n.º 5
0
 def error_check_relationship(relationship_value):
     """this method converts diagram to workable class
     """
     ErrorChecker.error_type(
         str, relationship_value,
         "SETUP RELATIONSHIP: data type is not corrected")
     try:
         rel_value = relationship_value.replace("--", ": ")
         return FormatData.format_relationship(rel_value)
     except Exception as e:
         print("RELATIONSHIP VALUE ERROR: ")
         print(e)
Ejemplo n.º 6
0
 def set_up_class_name(python_class_name):
     """this returns the class name
     """
     ErrorChecker.error_type(
         str, python_class_name,
         "ERROR: SETUP CLASS NAME: data type is not corrected")
     try:
         class_name = python_class_name.replace("class",
                                                '').replace('{', '')
         return class_name
     except Exception as e:
         print("PYTHON CLASS NAME ERROR: ")
         print(e)
Ejemplo n.º 7
0
 def set_up_method_name(method_name):
     """this removes the String from the method attributes
     """
     ErrorChecker.error_type(
         str, method_name, "SETUP METHOD NAME: data type is not corrected")
     try:
         temp_met = method_name.replace('void', '')
         format_method = FormatData.clear_up_data(temp_met).replace(
             'str ', '')
         return format_method
     except Exception as e:
         print("METHOD NAME ERROR: ")
         print(e)
Ejemplo n.º 8
0
    def file_writer(overall_content):
        """this writes to a file using dict as kes
        and having the values as the print outs
        the loop steps though each key in dict
        """
        output_file_name = ViewFileLocation.output_location()

        ErrorChecker.error_type(str, output_file_name,
                                "FILE NAME: datatype not corrected")
        ErrorChecker.error_type(list, overall_content,
                                "OVERALL DATA: datatype not corrected")
        ErrorChecker.error_name(ViewFileLocation.output_location(),
                                output_file_name,
                                "FILE IS NOT NAMED CORRECTLY")

        from Controller.main_controller import MainController
        with open(output_file_name, "w") as output_file:
            for item in overall_content:
                file_output = dict(item)
                print(f"", file=output_file)
                for k, v in file_output.items():
                    if 'class_name_key' in k:
                        MainController.class_print(v, output_file)
                    elif 'relationship_key' in k:
                        MainController.relationship_print(v, output_file)
                    elif 'attributes_key' in k:
                        MainController.attribute_print(v, output_file)
                    elif 'methods_key' in k:
                        MainController.methods_print(v, output_file)
Ejemplo n.º 9
0
    def file_reader(input_file_name):
        """this takes in a string and loops thought to
        get a list of strings
        it also checks the input and validates the data at the
        end before passing the data
        """
        overall_reader_file = []
        ErrorChecker.error_type(
            str, input_file_name,
            "FILE NAME DON\'T LOAD: data type is not corrected")
        ErrorChecker.error_name(ViewFileLocation.input_location(),
                                input_file_name,
                                "ERROR: INPUT FILE IS NOT FIND")

        from Controller.main_controller import MainController
        with open(input_file_name, 'r') as diagram_file:
            for line in diagram_file:
                temp_line = line.replace('\n', '').replace(' ', '')
                overall_reader_file.append(temp_line)
            if MainController.pass_validate_data(overall_reader_file):
                MainController.pass_set_up(overall_reader_file)
            else:
                print('ERROR: FILE DON\'T LOADED')