Skip to content

Commit

Permalink
fixing #272 folder not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
KamalMahanna committed Aug 30, 2024
1 parent 0b39f8c commit 70722b5
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 @@ -39,11 +50,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 @@ -61,11 +74,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 70722b5

Please sign in to comment.