Skip to content

Commit 3ea4495

Browse files
committed
New rearranging method
1 parent 403c8ac commit 3ea4495

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

core/process.py

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
from typing import Union
12

23
class Process:
34

45
def __init__(self, file_path: str=None):
56
self.file_path = file_path
7+
self.list = []
68

79
def read_spe_file(self) -> list:
810

@@ -119,6 +121,14 @@ def remove_markdown_items(self, _list: list) -> list:
119121
_translate = ['ATV','BGN','SE','LUI','GE','IEA',
120122
'ISA','GS','SBT','SRE']
121123

124+
# Adding because it wasn't specified if needed
125+
_translate.append('CRS')
126+
_translate.append('RQS!AQ!ZZ!PARENT')
127+
_translate.append('DTP!196!')
128+
_translate.append('DTP!197!')
129+
_translate.append('REF!PSM!')
130+
_translate.append('IN2!18!')
131+
122132
for sublist in _list:
123133
sublist[:] = [item for item in sublist if not any(str(item).startswith(remove) for remove in _translate)]
124134

@@ -213,4 +223,69 @@ def rearrange_list(self, _list: list) -> list:
213223
from pprint import pprint
214224
pprint(_list)
215225
print(len(_list))
216-
return _list
226+
return _list
227+
228+
def new_rearrange_list(self, _list: list, app_type: str) -> list:
229+
230+
new_list = []
231+
232+
cert_list_holder = []
233+
conduct_list_holder = []
234+
submit_transmit_app = []
235+
residency_list_holder = []
236+
237+
_types = self.find_app_types(_list)
238+
239+
# Focuses on only one app_type at a time
240+
for idx, app in enumerate(_types):
241+
if app == app_type:
242+
new_list.append(_list[idx])
243+
244+
# Remove the sections of each list to move easily relocate later
245+
for idx, apps in enumerate(new_list):
246+
cert_idx = 0
247+
conduct_idx = 0
248+
semester_idx = 0
249+
for idx, items in enumerate(apps):
250+
# Capturing Cert Questions
251+
if str(items).startswith('RQS!AQ!ZZ!FERPA CERT SWITCH!'):
252+
cert_idx = idx
253+
elif str(items).startswith('RQS!AQ!ZZ!TRUTH CERT SWITCH!'):
254+
cert_list_holder.append(apps[cert_idx: idx+1])
255+
for idx in range((idx+1)-cert_idx):
256+
apps.pop(cert_idx)
257+
# Capturing Conduct Questions
258+
elif str(items).startswith('RQS!AQ!ZZ!$ 4!!'):
259+
conduct_idx = idx
260+
elif str(items).startswith('RQS!AQ!ZZ!$ 11!!'):
261+
conduct_list_holder.append(apps[conduct_idx:idx+5])
262+
for idx in range((idx+5)-conduct_idx):
263+
apps.pop(conduct_idx)
264+
# Capturing SUBMIT/TRANSMIT times and Major|Term Information
265+
elif str(items).startswith('SSE!'):
266+
semester_idx = idx
267+
elif str(items).startswith('RQS!AQ!ZZ!APP SUBMIT/TRANSMIT!!'):
268+
submit_transmit_app.append(apps[semester_idx:idx+1])
269+
for idx in range((idx+1)-semester_idx):
270+
apps.pop(semester_idx)
271+
# Capturing Residency Questions
272+
elif str(items).startswith('RQS!AQ!ZZ!RES:'):
273+
print(items)
274+
residency_list_holder.append(items)
275+
276+
# Relocate each item in the separated list into the proper index
277+
for idx, apps in enumerate(new_list):
278+
for items in submit_transmit_app[idx]:
279+
apps.insert(0, items)
280+
# for items in residency_list_holder[idx]:
281+
# apps.append(items)
282+
for items in conduct_list_holder[idx]:
283+
apps.append(items)
284+
for items in cert_list_holder[idx]:
285+
apps.append(items)
286+
287+
from pprint import pprint
288+
#pprint(residency_list_holder)
289+
pprint(new_list)
290+
291+
return new_list

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def run(file_path: str, filename: str) -> None:
6565
spe_list = p.read_spe_file()
6666

6767
clean_list = p.remove_markdown_items(spe_list)
68-
new_list = p.rearrange_list(clean_list)
68+
new_list = p.new_rearrange_list(clean_list, 'U.S. Freshman Admission')
69+
# new_list = p.rearrange_list(clean_list)
6970

7071
# translated_spe = []
7172
# markdown_spe = []

0 commit comments

Comments
 (0)