def generate_response_dir(schema_path: str, destination_path: str) -> None: create_results_dir(destination_path) with open(schema_path, "r") as schema: json_dict = json.load(schema) titles = get_responses_titles(json_dict) filenames = split_responses_names(titles) create_python_files(destination_path, filenames) return filenames, json_dict
def write_translated_json(filepath_to: str, prepared_dict: dict, imports: dict) -> None: create_results_dir(filepath_to) with open(f'{filepath_to}/codegen.py', 'w') as pyfile: pyfile.write(str(Imports(**imports))) for classname in prepared_dict.keys(): class_form = schema_object_fabric_method(classname, prepared_dict) pyfile.write(str(class_form)) pyfile.write(str(UpdateForwardRefs(**prepared_dict)))
def write_translated_json(filepath_to: str, prepared_dict: dict, imports: dict, tabulation=" ") -> None: create_results_dir(filepath_to) with open(f"{filepath_to}/objects.py", "w") as file: text = str(Imports(**imports)) for classname in prepared_dict: class_form = schema_object_fabric_method(classname, prepared_dict) text += str(class_form) text += str(UpdateForwardRefs(**prepared_dict)) text = text.replace("\t", tabulation) file.write(text)
def parse_file(filepath: str, filepath_to: str, **imports) -> None: base_dir = create_results_dir(f'{filepath_to}/methods') categories = sort_jsonmethods_schema(filepath) for category, methods in categories.items(): with open(f"{base_dir}/{category}.py", 'w') as pyfile: construct_schema(pyfile, category, methods, **imports)
def parse_file(filepath: str, filepath_to: str, imports: dict, return_type_annotations: dict, tabulation=" ") -> None: base_dir = create_results_dir(f"{filepath_to}/methods") categories = sort_jsonmethods_schema(filepath) for category, methods in categories.items(): with open(f"{base_dir}/{category}.py", "w") as file: text = construct_schema(category, methods, imports, return_type_annotations[category]).replace( "\t", tabulation) file.write(text)