From 67543499ab881909d3f5496d6c6404235953fdcc Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Sat, 31 Aug 2024 15:41:33 -0700 Subject: [PATCH] update cmdline utility to match README --- .gitignore | 2 -- resume_yaml_generator.py | 27 ++++++++++++--------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 1e8e081..4e73720 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,3 @@ generated_cv* .vscode chrome_profile answers.json -resume.yaml -resume.yaml_validation_report.txt diff --git a/resume_yaml_generator.py b/resume_yaml_generator.py index 00e6922..dcc6607 100644 --- a/resume_yaml_generator.py +++ b/resume_yaml_generator.py @@ -130,35 +130,32 @@ def generate_report(validation_result: Dict[str, Any], output_file: str): report += validation_result["errors"] + "\n" print(report) - with open(f"{output_file}_validation_report.txt", 'w') as file: - file.write(report) def main(): parser = argparse.ArgumentParser(description="Generate a resume YAML file from a text resume using OpenAI API") - parser.add_argument("resume_file", help="Path to the input text resume file") - parser.add_argument("schema_file", help="Path to the YAML schema file") - parser.add_argument("output_file", help="Path to the output YAML file") + parser.add_argument("--input", required=True, help="Path to the input text resume file") + parser.add_argument("--output", default="data_folder/plain_text_resume.yaml", help="Path to the output YAML file") args = parser.parse_args() try: api_key = get_api_key() - schema = load_yaml(args.schema_file) - resume_text = load_resume_text(args.resume_file) + schema = load_yaml("assets/resume_schema.yaml") + resume_text = load_resume_text(args.input) generated_yaml = generate_yaml_from_resume(resume_text, schema, api_key) - save_yaml(generated_yaml, args.output_file) + save_yaml(generated_yaml, args.output) - print(f"Resume YAML generated and saved to {args.output_file}") + print(f"Resume YAML generated and saved to {args.output}") validation_result = validate_yaml(generated_yaml, schema) - generate_report(validation_result, args.output_file) + if validation_result["valid"]: + print("YAML is valid and conforms to the schema.") + else: + print("YAML is not valid. Errors:") + print(validation_result["errors"]) - except FileNotFoundError as e: - print(f"Error: {e}") - except ValueError as e: - print(f"Error: {e}") except Exception as e: - print(f"An unexpected error occurred: {e}") + print(f"An error occurred: {e}") if __name__ == "__main__": main() \ No newline at end of file