@@ -22,137 +22,102 @@ def read_spe_file(self) -> list:
22
22
23
23
return spe_list [1 :]
24
24
25
- def process_str_with_num (self , _str : str ) -> list :
25
+ def check_for_new_markdown (self , _list : list ) -> bool :
26
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
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.' )
68
37
69
- return [ str ( item ). strip () for item in _list if item != " " ]
38
+ return True
70
39
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 :
78
41
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 )]
84
47
85
48
return _list
86
49
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
114
71
115
72
def rearrange_markdown_list (self , _list : list ) -> list :
116
73
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 = [
119
81
'N1!TM!!ZZ!TXAPP' ,
120
82
'RQS!AQ!ZZ!APP SUBMIT/TRANSMIT!!' ,
121
83
'REF!48!' ,
122
84
'REF!SY!' ,
123
85
'SSE!' ,
124
86
'FOS!' ,
125
87
'RQS!AQ!ZZ!FORMER STUDENT!' ,
126
- 'N1!HS!' , 'HIGH SCHOOL LOCATION SKIP' ,
127
-
128
-
88
+ 'N1!HS!' ,
129
89
]
130
90
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
134
122
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
0 commit comments