Skip to content

Commit

Permalink
Merge pull request #284 from KamalMahanna/main
Browse files Browse the repository at this point in the history
fixing #272 folder not found error
  • Loading branch information
srbhr authored Dec 3, 2024
2 parents dd85181 + 70722b5 commit 6bff891
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions run_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 6bff891

Please sign in to comment.