-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_cv.py
114 lines (96 loc) · 2.54 KB
/
parse_cv.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
import os
from dotenv import load_dotenv
from spellchecker import SpellChecker
import string
import yaml
import json
import datetime
valid_words = [
"app",
"impactful",
"lifecycle",
"frontend",
"HIPAA",
"roadmap",
"triaged",
"gdpr",
"oauth",
"SDLC",
"roi",
"devs",
"backend",
"3d",
"architected",
"codebase",
"dd",
"containerized",
"ci",
"gui",
"webdriver",
"rois",
"ct",
"2d3d",
"github",
"slackbot",
"pr",
"qa",
"triaging",
"itg",
"dicom",
"poc",
"pkce",
"scottish",
"sso",
"cicd",
"phd",
"multi",
"codebases",
"architecting",
"datasets"
]
def DateEncoder(obj):
if isinstance(obj, (datetime.datetime, datetime.date)):
return obj.strftime('%Y-%m-%d')
def text_to_wordlist(text):
return text.replace("-", " ").translate(str.maketrans('', '', string.punctuation)).split()
def validate_information(data):
phone_validator = os.getenv("PHONE")
email_validator = os.getenv("EMAIL")
assert data["profile"]["phone"].replace("-", "") == phone_validator, "phone number incorrect"
assert data["profile"]["email"] == email_validator, "email incorrect"
def validate_spelling(data):
spell = SpellChecker()
spell.word_frequency.load_words(valid_words)
def check_unknown(text, field):
unknown = spell.unknown(text_to_wordlist(text))
assert len(unknown) == 0, f"\nfound misspelled words in {field}: {unknown}"
check_unknown(data["summary"], "summary")
for job in data["experience"]:
for note in job["notes"]:
check_unknown(note["note"], job["company"])
def main():
load_dotenv()
input_dir = os.getenv("CV_DATA_DIR")
input_filename = os.getenv("CV_FILE")
main_cv_filename = os.getenv("MAIN_CV_FILE")
print(input_filename)
output_dir = "./src/data"
with open(f"{input_dir}/{input_filename}") as input_file:
data = yaml.safe_load(input_file)
try:
if input_filename != main_cv_filename:
validate_information(data)
validate_spelling(data)
except AssertionError as error:
print(error)
response = input("continue anyway?")
if response in ["Y", "y"]:
pass
else:
exit(1)
with open(f"{output_dir}/cv.json", "w") as output_file:
output_file.write(json.dumps(data, indent=2, default=DateEncoder))
print("success fully wrote new cv file")
if __name__ == '__main__':
raise SystemExit(main())