forked from qqqstuv/Cover-Letter-Generator
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelper.py
More file actions
84 lines (70 loc) · 2.38 KB
/
helper.py
File metadata and controls
84 lines (70 loc) · 2.38 KB
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
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Inches, Cm
import re
from docx.shared import Pt
def format_size_and_font(format_obj):
format_obj.font.size = Pt(12)
def format_alignment(para_obj, inches=0.5):
para_obj.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
para_obj.paragraph_format.first_line_indent = Inches(inches)
return para_obj
def format_fill_in_info(format_obj, data):
replaceList = re.findall("\{.*?\}", format_obj)
for replace in replaceList:
replaceTo = replace.strip("{").strip("}")
format_obj = re.sub(replace, str(data[replaceTo]), format_obj)
return format_obj
def askYesNo(promptString=None):
print(promptString)
answer = input()
return False if not answer.isdigit() else int(answer)
#Ask for a string
def askInput(promptString=None):
print(promptString)
return input()
def askForChoice(choice_obj, promptString=None):
print(promptString, ", one of the following:")
choices = []
count = 0
for key, value in choice_obj.items():
string = '{:>12} : {:>12}'.format(count, key)
print(string)
choices.append(value)
count += 1
choice = input()
return choices[int(choice)]
def askForChoices(choice_obj, promptString=None):
print(promptString,", one or more of the following. Enter -1 to skip:")
choices = []
for key, value in choice_obj.items():
choices.append(key)
returnChoices = []
while(1):
count = 0
for aChoice in choices:
string = '{:>12} : {:>12}'.format(count, aChoice)
print(string)
count += 1
rawInput = input()
if rawInput == "a": # choose all
returnChoices = choices[:4] # hardcoded 4
break
elif rawInput != "":
indexes = [int(i) for i in rawInput.split(" ")]
for i in indexes:
returnChoices.append(choices[i])
break
else:
break
returnChoices = [choice_obj[choice] for choice in returnChoices]
return returnChoices
def sanitize_name(names):
returnName = ""
for name in names:
name = name \
.replace("(", "").replace(")", "") \
.replace(" ", "").replace("\/", "").replace("\\", "") \
.replace(".","").replace(",", "")
returnName += name + "_"
returnName += ".docx"
return returnName