Skip to content

Commit 7ebedd2

Browse files
committed
Multiple tries no results.
1 parent c9bc3e9 commit 7ebedd2

File tree

3 files changed

+96
-79
lines changed

3 files changed

+96
-79
lines changed

core/process.py

Lines changed: 78 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,83 @@ def read_spe_file(self) -> list:
2222

2323
return spe_list[1:]
2424

25+
def process_str_with_num(self, _str: str) -> list:
26+
27+
_list = []
28+
29+
for idx, item in enumerate(_str):
30+
if item.isnumeric():
31+
sep_idx = idx
32+
break
33+
34+
_list.append(str(_str[:sep_idx]).strip())
35+
_list.append(_str[sep_idx:])
36+
37+
return _list
38+
39+
def process_str_with_blank(self, _str: str) -> list:
40+
41+
_list = []
42+
43+
for idx, item in enumerate(_str):
44+
if item.isspace():
45+
sep_idx = idx
46+
break
47+
48+
_list.append(_str[:sep_idx])
49+
_list.append(str(_str[sep_idx:]).strip())
50+
51+
return _list
52+
53+
def process_str_with_blanks(self, _str: str) -> list:
54+
55+
sep_idx = []
56+
_list = []
57+
last = 0
58+
59+
for idx, item in enumerate(_str):
60+
if item.isspace():
61+
sep_idx.append(idx)
62+
63+
sep_idx.append(len(_str)-1)
64+
65+
for indicies in sep_idx:
66+
_list.append(_str[last:indicies])
67+
last = indicies
68+
69+
return [str(item).strip() for item in _list if item != " "]
70+
71+
def create_uniform_list(self, _list: list, max_items: int, max_chars: int) -> list:
72+
73+
for idx, item in enumerate(_list):
74+
if len(item) > max_chars:
75+
del(_list[idx])
76+
_list.insert(idx, item[:max_chars])
77+
_list.insert(idx+1, item[max_chars:])
78+
79+
while len(_list) < max_items:
80+
if len(_list) == max_items-1:
81+
_list.append('0')
82+
else:
83+
_list.append('000000')
84+
85+
return _list
86+
87+
def create_uniform_item(self, _str: str, max_char: int) -> str:
88+
89+
while len(_str) < max_char:
90+
_str = _str + '0'
91+
92+
return _str
93+
94+
def create_uniform_items(self, _list: list, max_char: list) -> list:
95+
96+
for idx, item in enumerate(_list):
97+
if len(item) != max_char[idx]:
98+
_list[idx] = self.create_uniform_item(item, max_char[idx])
99+
100+
return _list
101+
25102
def check_for_new_markdown(self, _list: list) -> bool:
26103

27104
_translate = ['ATV','BGN','COM','CRS','DEG','DMG','DTP','FOS',
@@ -67,57 +144,4 @@ def find_app_types(self, _list: list) -> list:
67144
if str(item).startswith('REF!48!'):
68145
_apps.append(_tranlsate.get(str(item).split('!')[-1].strip('\\'), 'Other'))
69146

70-
return _apps
71-
72-
def rearrange_markdown_list(self, _list: list) -> list:
73-
74-
app_list = self.find_app_types(_list)
75-
updated_list = self.remove_markdown_items(_list)
76-
77-
from pprint import pprint
78-
pprint(updated_list)
79-
80-
_example = [
81-
'N1!TM!!ZZ!TXAPP',
82-
'RQS!AQ!ZZ!APP SUBMIT/TRANSMIT!!',
83-
'REF!48!',
84-
'REF!SY!',
85-
'SSE!',
86-
'FOS!',
87-
'RQS!AQ!ZZ!FORMER STUDENT!',
88-
'N1!HS!',
89-
]
90-
91-
for idx, sublist in enumerate(updated_list):
92-
sublist[:] = [item for item in sublist if any(str(item).startswith(add) for add in _example)]
93-
94-
return updated_list
95-
96-
# insert_no_matter_what = [
97-
# 'RQS!AQ!ZZ!FORMER STUDENT!'
98-
# ]
99-
100-
# output = _list.copy()
101-
102-
# for apps in output:
103-
# for idx, item in enumerate(apps):
104-
# for e_idx, e_item in enumerate(example):
105-
# # if e_item not in apps and e_item in insert_no_matter_what:
106-
# # print(f'Item {item} was not found!, inserting at index {e_idx} anyways.')
107-
# # apps.insert(e_idx, e_item)
108-
# if str(item).startswith(e_item):
109-
110-
# if e_item == 'N1!HS!':
111-
# hs_name = apps.pop(idx)
112-
# hs_loc = apps.pop(idx)
113-
# apps.insert(e_idx, hs_name)
114-
# apps.insert(e_idx+1, hs_loc)
115-
116-
# else:
117-
# # print(f'\n{item} found in example list, {e_item}')
118-
# # print(f'Popping item idx {idx} from apps list')
119-
# apps.pop(idx) # Remove from list before moving
120-
# # print(f'Inserting {item} at index {e_idx} for apps list')
121-
# apps.insert(e_idx, item) # Move removed item to correct spot in list
122-
123-
# return output
147+
return _apps

core/structure.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def translate_DEG(self) -> str:
235235
_translate = {
236236
'2.2': 'Certificate:',
237237
'2.3': 'Compeleted:',
238-
'2.4': 'Major:',
238+
'2.4': 'Major(s):',
239239
'3.1': 'Degree: Professional',
240240
'4.1': 'No Degree',
241241
'4.2': 'Degree: Masters (M.)',
@@ -326,7 +326,6 @@ def translate_FOS(self) -> str:
326326

327327
if sep == 'Major':
328328
return f'{sep}: [{self.target[3]}] {self.target[-1]}'
329-
# return self.output.insert(self.student_idx+2, f'{sep}: [{self.target[3]}] {self.target[-1]}')
330329
else:
331330
return f'{sep}: {self.target[-1]}'
332331

@@ -573,7 +572,7 @@ def translate_REF(self) -> str:
573572

574573
_translate = {
575574
'48': 'App ID',
576-
'SY': 'SSN Info',
575+
'SY': '1. Social Security Number',
577576
'V2': 'F-1 status',
578577
'PSM': 'Previous App',
579578
'ZZ': 'Premanent Residence status'
@@ -619,8 +618,7 @@ def translate_RQS(self) -> list:
619618
return s.OTHER_NAME()
620619

621620
if self.target[3] == 'APP SUBMIT/TRANSMIT':
622-
return ['', self.target[-1], '']
623-
return self.output.insert(2, ['', self.target[-1], ''])
621+
return ['', f'APPLICATION {self.target[-1][:28]}', f'APPLICATION {self.target[-1][30:]}', '']
624622

625623
if self.target[3] == 'CUR COLLEGE CRS':
626624
if self.cur_college_crs_check == 0:
@@ -707,7 +705,7 @@ def translate_RQS(self) -> list:
707705
'FAMILY OBLIGATION OTHER': None,
708706
'FAMILY OBLIGATIONS': ['Do you have family obligations that keep you from participating in extracurricular activities?',
709707
basic_output, ''],
710-
'DUAL CREDIT': ['', 'Are you applyting to take college courses to be completed while you are still',
708+
'DUAL CREDIT': ['Biographical Information', '', 'Are you applyting to take college courses to be completed while you are still',
711709
'a high school student (Dual Credit or Concurrent Enrollment)?',
712710
basic_output, ''],
713711
'GRADUATE AWARD': None,
@@ -828,9 +826,7 @@ def translate_SSE(self) -> str:
828826
sep = _translate.get(self.target[-1][4:], self.target[-1][4:])
829827
if self.semester_check == 0:
830828
self.semester_check = 1
831-
# self.output.insert(self.student_idx, f'{sep} {self.target[-1][:4]}')
832-
# return self.output.insert(self.student_idx, '')
833-
return f'{sep} {self.target[-1][:4]}'
829+
return f'Semester Applied For: {sep} {self.target[-1][:4]}'
834830
elif self.target[-1] == 'ZZZ':
835831
return f'(Attendance dates: {self.target[1][4:6]}/{self.target[1][:4]} - {self.target[2][4:6]}/{self.target[2][:4]})'
836832

main.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,23 @@ def run(file_path: str, filename: str) -> None:
6464
p = core.Process(file_path)
6565
spe_list = p.read_spe_file()
6666

67-
new_list = p.rearrange_markdown_list(spe_list)
67+
new_list = p.remove_markdown_items(spe_list)
6868

69-
# from pprint import pprint
70-
# pprint(new_list)
69+
translated_spe = []
70+
markdown_spe = []
7171

72-
# translated_spe = []
73-
# markdown_spe = []
74-
75-
# for idx, item in enumerate(new_list):
76-
# s = core.Structure(item, idx)
77-
# translated_spe.append(s.translate())
78-
# markdown_spe.append(s.markdown)
72+
for idx, item in enumerate(new_list):
73+
s = core.Structure(item, idx)
74+
translated_spe.append(s.translate())
75+
markdown_spe.append(s.markdown)
7976

80-
# r = core.PDF(translated_spe)
81-
# r.capture_student_name()
82-
# r.capture_app_type()
77+
r = core.PDF(translated_spe)
78+
r.capture_student_name()
79+
r.capture_app_type()
8380

84-
# for idx, item in enumerate(translated_spe):
85-
# _list = r.fit_student_data(item)
86-
# r.create_page_structure(folder, filename, _list, idx)
81+
for idx, item in enumerate(translated_spe):
82+
_list = r.fit_student_data(item)
83+
r.create_page_structure(folder, filename, _list, idx)
8784

8885
except BaseException as b:
8986
print(sys.exc_info())

0 commit comments

Comments
 (0)