diff --git a/run_first.py b/run_first.py index 9a198cb..677b1ea 100644 --- a/run_first.py +++ b/run_first.py @@ -7,8 +7,19 @@ init_logging_config() -PROCESSED_RESUMES_PATH = "Data/Processed/Resumes" -PROCESSED_JOB_DESCRIPTIONS_PATH = "Data/Processed/JobDescription" +script_dir = os.path.dirname(os.path.abspath(__file__)) +PROCESSED_DATA_PATH = os.path.join(script_dir, "Data", "Processed") +PROCESSED_RESUMES_PATH = os.path.join(PROCESSED_DATA_PATH, "Resumes") +PROCESSED_JOB_DESCRIPTIONS_PATH = os.path.join( + PROCESSED_DATA_PATH, "JobDescription" +) + +# check if processed data directory exists +if not os.path.exists(PROCESSED_DATA_PATH): + os.makedirs(PROCESSED_DATA_PATH) + os.makedirs(PROCESSED_RESUMES_PATH) + os.makedirs(PROCESSED_JOB_DESCRIPTIONS_PATH) + logging.info("Created necessary directories.") def read_json(filename): @@ -46,11 +57,13 @@ def remove_old_files(files_path): file_names = get_filenames_from_dir("Data/Resumes") logging.info("Reading from Data/Resumes is now complete.") -except: +except Exception: # Exit the program if there are no resumes. logging.error("There are no resumes present in the specified folder.") logging.error("Exiting from the program.") - logging.error("Please add resumes in the Data/Resumes folder and try again.") + logging.error( + "Please add resumes in the Data/Resumes folder and try again." + ) exit(1) # Now after getting the file_names parse the resumes into a JSON Format. @@ -72,11 +85,15 @@ def remove_old_files(files_path): file_names = get_filenames_from_dir("Data/JobDescription") logging.info("Reading from Data/JobDescription is now complete.") -except: +except Exception: # Exit the program if there are no resumes. - logging.error("There are no job-description present in the specified folder.") + logging.error( + "There are no job-description present in the specified folder." + ) logging.error("Exiting from the program.") - logging.error("Please add resumes in the Data/JobDescription folder and try again.") + logging.error( + "Please add resumes in the Data/JobDescription folder and try again." + ) exit(1) # Now after getting the file_names parse the resumes into a JSON Format.