Skip to content

Commit c9bc3e9

Browse files
committed
initial test branch
started the refactoring for the logic needed to filter the app data into a applytexas structure.
1 parent 324aa70 commit c9bc3e9

File tree

4 files changed

+95
-221
lines changed

4 files changed

+95
-221
lines changed

core/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from .pdf import *
2-
from .xlsx import *
32
from .structure import *
43
from .process import *
54
from .syntax import *

core/process.py

Lines changed: 79 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -22,137 +22,102 @@ def read_spe_file(self) -> list:
2222

2323
return spe_list[1:]
2424

25-
def process_str_with_num(self, _str: str) -> list:
25+
def check_for_new_markdown(self, _list: list) -> bool:
2626

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
27+
_translate = ['ATV','BGN','COM','CRS','DEG','DMG','DTP','FOS',
28+
'IN1','IN2','IND','MSG','N1','N3','N4','NTE','PCL',
29+
'REF','RQS','MSG','SE','SES','SSE','SST','SUM',
30+
'TST','LUI','GE','IEA','ISA','GS','SBT','SRE','LT']
31+
32+
for apps in _list:
33+
for item in apps:
34+
check = str(item).split('!')
35+
if check[0] not in _translate:
36+
raise ReferenceError(f'ERROR! {item} is not captured.')
6837

69-
return [str(item).strip() for item in _list if item != " "]
38+
return True
7039

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:])
40+
def remove_markdown_items(self, _list: list) -> list:
7841

79-
while len(_list) < max_items:
80-
if len(_list) == max_items-1:
81-
_list.append('0')
82-
else:
83-
_list.append('000000')
42+
_translate = ['ATV','BGN','SE','LUI','GE','IEA',
43+
'ISA','GS','SBT','SRE']
44+
45+
for sublist in _list:
46+
sublist[:] = [item for item in sublist if not any(str(item).startswith(remove) for remove in _translate)]
8447

8548
return _list
8649

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-
102-
def filter_markdown_text(self, _list: list) -> list:
103-
104-
output = []
105-
106-
for apps in _list:
107-
current = []
108-
for items in apps:
109-
markdown = str(items).split('!')
110-
current.append("!".join(markdown[:-1]))
111-
output.append(current)
112-
113-
return output
50+
def find_app_types(self, _list: list) -> list:
51+
52+
_apps = []
53+
54+
_tranlsate = {
55+
'FFRESHMAN APPLICATION ID': 'U.S. Freshman Admission',
56+
'IFOREIGN GRAD APPLICATION ID': 'International Graduate Admission',
57+
'CREENTRY UNDERGRAD APPLICATION ID': 'U.S. Re-Entry Admission',
58+
'GUS GRAD APPLICATION ID': 'U.S. Graduate Admission',
59+
'TUS TRANSFER APPLICATION ID': 'U.S. Transfer Admission',
60+
'AFOREIGN TRANSFER APPLICATION ID': 'International Transfer Admission',
61+
'BFOREIGN FRESHMAN APPLICATION ID': 'International Freshman Admission',
62+
'SUS TRANSIENT APPLICATION ID': 'Transient Admission',
63+
}
64+
65+
for sublist in _list:
66+
for item in sublist:
67+
if str(item).startswith('REF!48!'):
68+
_apps.append(_tranlsate.get(str(item).split('!')[-1].strip('\\'), 'Other'))
69+
70+
return _apps
11471

11572
def rearrange_markdown_list(self, _list: list) -> list:
11673

117-
example = [
118-
'BGN!00!',
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 = [
11981
'N1!TM!!ZZ!TXAPP',
12082
'RQS!AQ!ZZ!APP SUBMIT/TRANSMIT!!',
12183
'REF!48!',
12284
'REF!SY!',
12385
'SSE!',
12486
'FOS!',
12587
'RQS!AQ!ZZ!FORMER STUDENT!',
126-
'N1!HS!', 'HIGH SCHOOL LOCATION SKIP',
127-
128-
88+
'N1!HS!',
12989
]
13090

131-
insert_no_matter_what = [
132-
'RQS!AQ!ZZ!FORMER STUDENT!'
133-
]
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
134122

135-
output = _list.copy()
136-
137-
for apps in output:
138-
for idx, item in enumerate(apps):
139-
for e_idx, e_item in enumerate(example):
140-
# if e_item not in apps and e_item in insert_no_matter_what:
141-
# print(f'Item {item} was not found!, inserting at index {e_idx} anyways.')
142-
# apps.insert(e_idx, e_item)
143-
if str(item).startswith(e_item):
144-
145-
if e_item == 'N1!HS!':
146-
hs_name = apps.pop(idx)
147-
hs_loc = apps.pop(idx)
148-
apps.insert(e_idx, hs_name)
149-
apps.insert(e_idx+1, hs_loc)
150-
151-
else:
152-
# print(f'\n{item} found in example list, {e_item}')
153-
# print(f'Popping item idx {idx} from apps list')
154-
apps.pop(idx) # Remove from list before moving
155-
# print(f'Inserting {item} at index {e_idx} for apps list')
156-
apps.insert(e_idx, item) # Move removed item to correct spot in list
157-
158-
return output
123+
# return output

core/xlsx.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

main.py

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

67-
translated_spe = []
68-
markdown_spe = []
69-
7067
new_list = p.rearrange_markdown_list(spe_list)
7168

72-
from pprint import pprint
73-
pprint(new_list)
69+
# from pprint import pprint
70+
# pprint(new_list)
71+
72+
# translated_spe = []
73+
# markdown_spe = []
7474

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)
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)
7979

80-
r = core.PDF(translated_spe)
81-
r.capture_student_name()
82-
r.capture_app_type()
80+
# r = core.PDF(translated_spe)
81+
# r.capture_student_name()
82+
# r.capture_app_type()
8383

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

8888
except BaseException as b:
89+
print(sys.exc_info())
8990
tk.messagebox.showerror("run() error", f"{sys.exc_info()[1]}")
9091

9192
if __name__ == "__main__":

0 commit comments

Comments
 (0)