Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 269, deleting pre-existing files error #271

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,6 @@ scripts/similarity/config.yml
# Processed or local files
/Data/Processed/*
*.local.pdf

# ASDF version manager
.tool-versions
7 changes: 3 additions & 4 deletions resume_matcher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@


def get_filenames_from_dir(directory):
return [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))]
return [
f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))
]


def process_files(resume, job_description):
Expand All @@ -34,6 +36,3 @@ def process_files(resume, job_description):
print(r.score)
print(f"Processing resume: {resume}")
print(f"Processing job description: {job_description}")



7 changes: 6 additions & 1 deletion run_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ def read_json(filename):


def remove_old_files(files_path):
try:
filenames = os.listdir(files_path)
except FileNotFoundError:
logging.info(f"Directory {files_path} does not exist. No files to remove")
return

for filename in os.listdir(files_path):
for filename in filenames:
try:
file_path = os.path.join(files_path, filename)

Expand Down
2 changes: 2 additions & 0 deletions scripts/JobDescriptionProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .parsers import ParseJobDesc, ParseResume
from .ReadPdf import read_single_pdf
from .utils import make_sure_path_exists

READ_JOB_DESCRIPTION_FROM = "Data/JobDescription/"
SAVE_DIRECTORY = "Data/Processed/JobDescription"
Expand Down Expand Up @@ -41,6 +42,7 @@ def _write_json_file(self, resume_dictionary: dict):
+ ".json"
)
save_directory_name = pathlib.Path(SAVE_DIRECTORY) / file_name
make_sure_path_exists(SAVE_DIRECTORY)
json_object = json.dumps(resume_dictionary, sort_keys=True, indent=14)
with open(save_directory_name, "w+") as outfile:
outfile.write(json_object)
2 changes: 2 additions & 0 deletions scripts/ResumeProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .parsers import ParseJobDesc, ParseResume
from .ReadPdf import read_single_pdf
from .utils import make_sure_path_exists

READ_RESUME_FROM = "Data/Resumes/"
SAVE_DIRECTORY = "Data/Processed/Resumes"
Expand Down Expand Up @@ -38,6 +39,7 @@ def _write_json_file(self, resume_dictionary: dict):
"Resume-" + self.input_file + resume_dictionary["unique_id"] + ".json"
)
save_directory_name = pathlib.Path(SAVE_DIRECTORY) / file_name
make_sure_path_exists(SAVE_DIRECTORY)
json_object = json.dumps(resume_dictionary, sort_keys=True, indent=14)
with open(save_directory_name, "w+") as outfile:
outfile.write(json_object)
4 changes: 4 additions & 0 deletions scripts/utils/ReadFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ def get_filenames_from_dir(directory_path: str) -> list:
if os.path.isfile(os.path.join(directory_path, f)) and f != ".DS_Store"
]
return filenames


def make_sure_path_exists(directory_path: str):
os.makedirs(directory_path, exist_ok=True)
2 changes: 1 addition & 1 deletion scripts/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .logger import init_logging_config
from .ReadFiles import get_filenames_from_dir
from .ReadFiles import get_filenames_from_dir, make_sure_path_exists
from .Utils import TextCleaner