Skip to content

Commit b7221e7

Browse files
committed
Finished SELF syntax
Finished up all of the code for the SELF syntax questions. Need to fix up the code to match what is currently done for GUAR.
1 parent f098c7e commit b7221e7

File tree

3 files changed

+181
-75
lines changed

3 files changed

+181
-75
lines changed

core/process.py

Lines changed: 151 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ def find_largest_row(self, input: list) -> int:
3434
return largest
3535

3636

37-
def find_largest_index(self, input: list) -> int:
38-
"""Based on the largest row found, returns the index with the row
37+
def find_largest_char(self, input: list) -> int:
38+
"""Based on the largest row found, returns the char with the row
3939
from a given nested list.
4040
4141
:param input: nested list of varying length
4242
:type input: list
43-
:return: index of largest row
43+
:return: char of largest row
4444
:rtype: int
4545
"""
4646

4747
largest = self.find_largest_row(input)
4848

4949
for row in range(len(input)):
5050
if largest == len(input[row]):
51-
index = row
51+
char = row
5252

53-
return index
53+
return char
5454

5555

5656
def read_csv_file(self) -> list:
@@ -77,7 +77,7 @@ def read_csv_file(self) -> list:
7777
return self.data
7878

7979
def create_data_list(self, input: list) -> Union[list, list]:
80-
"""Creation of two data list based on destinction found at index 5
80+
"""Creation of two data list based on destinction found at char 5
8181
for each row.
8282
8383
:param input: nested list of rows found
@@ -109,8 +109,8 @@ def uniform_data_list(self, input: list) -> list:
109109
:rtype: list
110110
"""
111111

112-
template_index = self.find_largest_index(input)
113-
template_list = input[template_index]
112+
template_char = self.find_largest_char(input)
113+
template_list = input[template_char]
114114

115115
# Initialize an empty result list
116116
result_nested_list = []
@@ -197,7 +197,7 @@ def uniform_data_list_2(self, input: list) -> list:
197197
:return: updated nested list of same length
198198
:rtype: list
199199
"""
200-
template_idx = self.find_largest_index(input)
200+
template_idx = self.find_largest_char(input)
201201
template_list = input[template_idx]
202202
template_markdown = []
203203

@@ -281,79 +281,142 @@ def process_str(self, _str: str) -> list:
281281

282282
def process_guar(self, _list: list) -> list:
283283

284-
# example_list = ['N', 'Y', 'NONE OF THE ABOVE', 'Y2535H', 'N000000N000000', '000000NN', '0000N']
284+
syntax = {
285+
'N': 'No',
286+
'Y': 'Yes',
287+
'K': 'Not provided',
288+
'H': 'Establish/Maintain a home',
289+
'000000': 'Not provided'
290+
}
291+
292+
if len(_list) == 11:
293+
_list.insert(2, ' '.join(_list[2:7]))
294+
del(_list[3:8])
295+
elif len(_list) == 5:
296+
_list.insert(1, 'Not provided')
297+
_list.insert(2, 'Not provided')
298+
elif len(_list) == 4:
299+
_list.insert(1, 'Not provided')
300+
_list.insert(2, 'Not provided')
301+
if len(_list[-1]) > 13:
302+
val = _list[-1]
303+
_list.insert(-1, val[:8])
304+
_list[-1] = val[8:]
305+
306+
if len(_list[3]) == 5:
307+
_list[3] += 'K'
308+
elif len(_list[3]) == 19:
309+
_list[3] += 'K'
310+
val = _list[3]
311+
del(_list[3])
312+
_list.insert(3, val[:6])
313+
_list.insert(4, val[6:])
314+
elif len(_list[3]) == 20:
315+
val = _list[3]
316+
del(_list[3])
317+
_list.insert(3, val[:6])
318+
_list.insert(4, val[6:])
319+
320+
val = _list[3]
321+
del(_list[3])
322+
_list.insert(3, val[0])
323+
_list.insert(4, f'{val[3:5]} months; {val[1:3]} years')
324+
_list.insert(5, val[5])
325+
_list.insert(6, 'K')
326+
_list.insert(7, 'K')
327+
328+
val = _list[8]
329+
del(_list[8])
330+
_list.insert(8, f'{val[0]} -- {val[1:3]}/{val[3:7]}')
331+
_list.insert(9, val[7])
285332

286-
new_list = []
287-
# modified = []
288-
_str = ''
289-
skip_idx = 0
290-
291-
for i, item in enumerate(_list):
292-
if item == 'NONE':
293-
_str += f'{_list[i]} {_list[i+1]} {_list[i+2]} {_list[i+3]}'
294-
skip_idx = i+3
295-
new_list.append(_str)
296-
elif i > skip_idx or i == 0:
297-
new_list.append(item)
298-
299-
# print(new_list)
300-
# given_index = 0
301-
302-
# for item in example_list:
303-
# if given_index < len(new_list) and len(new_list[given_index]) == len(item) or len(new_list[given_index]) == len(item)-1:
304-
# modified.append(new_list[given_index])
305-
# given_index += 1
306-
# else:
307-
# modified.append('N/A')
308-
309-
return new_list
333+
val = _list[10]
334+
final = _list[11]
335+
del(_list[10])
336+
del(_list[10])
337+
_list.insert(10, val[-1])
338+
_list.insert(11, final[-1])
339+
_list.insert(12, val[-2])
340+
_list.insert(13, val[:-2])
341+
_list.insert(14, f'{final[2:4]} months; {final[:2]} years')
342+
343+
_list.insert(2, 'K')
344+
345+
346+
347+
348+
349+
350+
for idx in range(len(_list)):
351+
for key, value in syntax.items():
352+
if key == _list[idx]:
353+
_list[idx] = value
354+
break
355+
356+
return _list
310357

311358
def process_self(self, _list: list) -> list:
312359

313-
print(_list)
314-
315360
new_list = []
316361

317-
if len(_list) == 4:
362+
if len(_list) == 8 or len(_list) == 9:
363+
new_list.append(' '.join(_list[1:5]))
364+
del(_list[1:5])
365+
elif len(_list[1]) == 23:
366+
_list.insert(2, _list[1][6:])
367+
_list[1] = _list[1][:6]
368+
new_list.append(str(_list[0]).replace(' ', 'Not provided'))
369+
else:
318370
new_list.append(str(_list[0]).replace(' ', 'Not provided'))
371+
372+
if len(_list) == 4:
319373
if len(_list[1]) == 5:
320374
new_list.append(str(_list[1][0]).replace('Y', 'Yes').replace('N', 'No'))
321375
new_list.append(f"{_list[1][1:3]} Years {_list[1][3:5]} Months")
322376
new_list.append('Not provided')
323377
elif len(_list[1]) == 6:
324-
new_list.append(str(_list[1][0]).replace('Y', 'Yes'))
378+
new_list.append(str(_list[1][0]).replace('Y', 'Yes').replace('N', 'No'))
325379
new_list.append(f"{_list[1][1:3]} Years {_list[1][3:5]} Months")
326-
new_list.append(str(_list[1][5]).replace('H', 'Establish/Maintain a home'))
380+
new_list.append(str(_list[1][5]).replace('C', 'Go to College').replace('H', 'Establish/Maintain a home').replace('W', 'Work Assignment'))
327381
elif len(_list[1]) == 23:
328382
new_list.append(str(_list[1][0]).replace('Y', 'Yes').replace('N', 'No'))
329-
new_list.append(f"{_list[1][1:3]} Years {_list[2][3:5]} Months")
330-
new_list.append(str(_list[1][5]).replace('C', 'Go to College'))
383+
new_list.append(f"{_list[1][1:3]} Years {_list[1][3:5]} Months")
384+
new_list.append(str(_list[1][5]).replace('C', 'Go to College').replace('H', 'Establish/Maintain a home').replace('W', 'Work Assignment'))
331385
new_list.append(str(_list[1][6]).replace('Y', 'Yes').replace('N', 'No'))
332386
new_list.append(str(_list[1][7:9]))
333-
new_list.append(str(_list[1][9]).replace('Y', 'Yes').replace('N', 'No'))
387+
new_list.append(f'{_list[1][9]}--acquired: {_list[1][14:16]}, {_list[1][10:14]}')
334388
new_list.append(str(_list[1][16]).replace('Y', 'Yes').replace('N', 'No'))
335-
336389

337-
if len(len(_list[2])) == 8:
390+
if len(_list[2]) == 8:
338391
new_list.append(str(_list[2][-2]).replace('Y', 'Yes').replace('N', 'No'))
339392
new_list.append(str(_list[2][-1]).replace('Y', 'Yes').replace('N', 'No'))
340393
elif len(_list[2]) == 14:
341-
new_list.append(str(_list[2][1:7]).replace('000000', 'No'))
342-
new_list.append(str(_list[2][8:14]).replace('000000', 'No'))
343-
new_list.append(str(_list[2][0]).replace('Y', 'Yes').replace('N', 'No'))
344-
new_list.append(str(_list[2][7]).replace('Y', 'Yes').replace('N', 'No'))
394+
if _list[2][1:7] == '000000':
395+
new_list.append('Not provided')
396+
new_list.append('Not provided')
397+
new_list.append(str(_list[2][0]).replace('Y', 'Yes').replace('N', 'No'))
398+
new_list.append(f'{_list[2][7]}--acquired: {_list[2][12:]}, {_list[2][8:12]}')
399+
elif _list[2][8:] == '000000':
400+
new_list.append('Not provided')
401+
new_list.append('Not provided')
402+
new_list.append(f'{_list[2][0]}--acquired: {_list[2][5:7]}, {_list[2][1:5]}')
403+
new_list.append(str(_list[2][7]).replace('Y', 'Yes').replace('N', 'No'))
404+
else:
405+
new_list.append('Not provided')
406+
new_list.append('Not provided')
407+
new_list.append(f'{_list[2][0]}--acquired: {_list[2][5:7]}, {_list[2][1:5]}')
408+
new_list.append(f'{_list[2][7]}--acquired: {_list[2][12:]}, {_list[2][8:12]}')
345409
elif len(_list[2]) == 16:
346410
new_list.append('Not provided')
347411
new_list.append(_list[2][0:2])
348-
new_list.append(f"{_list[2][2]}--acquired: {_list[2][3:7]},{_list[2][7:9]}")
412+
new_list.append(f"{_list[2][2]}--acquired: {_list[2][3:7]}, {_list[2][7:9]}")
349413
new_list.append(str(_list[2][9]).replace('Y', 'Yes').replace('N', 'No'))
350414
elif len(_list[2]) == 17:
351415
new_list.append(str(_list[2][0]).replace('Y', 'Yes').replace('N', 'No'))
352416
new_list.append(str(_list[2][1:3]))
353-
new_list.append(str(_list[2][3]).replace('Y', 'Yes').replace('N', 'No'))
417+
new_list.append(f'{_list[2][3]}--acquired: {_list[2][8:10]}, {_list[2][4:8]}')
354418
new_list.append(str(_list[2][10]).replace('Y', 'Yes').replace('N', 'No'))
355419

356-
357420
if len(_list[3]) == 5:
358421
new_list.append(str(_list[3][-1]).replace('Y', 'Yes').replace('N', 'No'))
359422
new_list.append("Not provided")
@@ -362,7 +425,43 @@ def process_self(self, _list: list) -> list:
362425
new_list.append(str(_list[3][6]).replace('Y', 'Yes').replace('N', 'No'))
363426
new_list.append(str(_list[3][-1]).replace('Y', 'Yes').replace('N', 'No'))
364427
new_list.append(str(_list[3][7]).replace('Y', 'Yes').replace('N', 'No'))
365-
new_list.append(str(_list[3][8]).replace('E', 'Gainfully employed'))
428+
new_list.append(str(_list[3][8]).replace('E', 'Gainfully employed').replace('P', 'Owns Property'))
366429
new_list.append(f"{_list[3][9:11]} Years {_list[3][11:13]} Months")
367430

431+
elif len(_list) == 5:
432+
433+
if len(_list[1]) == 5:
434+
new_list.append(str(_list[1][0]).replace('Y', 'Yes').replace('N', 'No'))
435+
new_list.append(f"{_list[1][1:3]} Years {_list[1][3:5]} Months")
436+
new_list.append('Not provided')
437+
elif len(_list[1]) == 6:
438+
new_list.append(str(_list[1][0]).replace('Y', 'Yes').replace('N', 'No'))
439+
new_list.append(f"{_list[1][1:3]} Years {_list[1][3:5]} Months")
440+
new_list.append(str(_list[1][5]).replace('C', 'Go to College').replace('H', 'Establish/Maintain a home').replace('W', 'Work Assignment'))
441+
442+
if len(_list[2]) == 14:
443+
new_list.append(str(_list[2][-3:]).replace('000', 'Not provided'))
444+
new_list.append(str(_list[2][-6:-3]).replace('000', 'Not provided'))
445+
new_list.append(f'{_list[2][0]}--acquired: {_list[2][5:7]}, {_list[2][1:5]}')
446+
new_list.append(str(_list[2][7]).replace('Y', 'Yes').replace('N', 'No'))
447+
elif len(_list[2]) == 16:
448+
new_list.append('Not provided')
449+
new_list.append(str(_list[2][0:2]))
450+
new_list.append(f'{_list[2][2]}--acquired: {_list[2][7:9]}, {_list[2][3:7]}')
451+
new_list.append(str(_list[2][9]).replace('Y', 'Yes').replace('N', 'No'))
452+
elif len(_list[2]) == 17:
453+
new_list.append(str(_list[2][0]).replace('Y', 'Yes').replace('N', 'No'))
454+
new_list.append(str(_list[2][1:3]))
455+
new_list.append(f'{_list[2][3]}--acquired: {_list[2][8:10]}, {_list[2][4:8]}')
456+
new_list.append(str(_list[2][10]).replace('Y', 'Yes').replace('N', 'No'))
457+
458+
if len(_list[3]) == 8:
459+
new_list.append(str(_list[3][-2]).replace('Y', 'Yes').replace('N', 'No'))
460+
new_list.append(str(_list[4][-1]).replace('Y', 'Yes').replace('N', 'No'))
461+
new_list.append(str(_list[3][:6]).replace('000000', 'No'))
462+
463+
if len(_list[4]) == 5:
464+
new_list.append(str(_list[3][-1]).replace('N', 'Not provided'))
465+
new_list.append(f"{_list[4][:2]} Years {_list[4][2:4]} Months")
466+
368467
return new_list

core/syntax.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ def residency_self_syntax(self, _list: list, name: str) -> list:
343343
if output[-1] == '0000':
344344
return
345345

346-
print(f'SELF: {output}', len(output), name)
346+
# print(f'SELF: {output}', len(output), name)
347347
ans = self.p.process_self(output)
348-
print(ans)
348+
# print(ans)
349349

350350
return ['Residency Information:',
351351
'4. If you are not a U.S. Citizen or U.S. Permanent Resident, are youa foreign national',
@@ -381,41 +381,42 @@ def residency_guar_syntax(self, _list: list, name: str) -> list:
381381
if output[-1] == '0000':
382382
return
383383

384-
# output = self.p.process_guar(_list)
385384
print(f'GUAR: {output}', len(output), name)
385+
ans = self.p.process_guar(output)
386+
print(ans)
386387

387388
return ['Residency Information:',
388389
'1. Is the parent or legal guardian upon whom you base your claim of residency a U.S.',
389-
'Citizen?', '',
390+
'Citizen?', f'{ans[0]}', '',
390391
'2. If no, does the parent or legal guardian upopn whom you base your claim residency',
391-
'hold Permanent Residence Status (valid I-551) for the U.S.?' '',
392+
'hold Permanent Residence Status (valid I-551) for the U.S.?' f'{ans[1]}', '',
392393
'3. Is this parent or legal guardian a foreign national whose application for Permanent',
393-
'Resident Status has been preliminarily reviewed?', '',
394+
'Resident Status has been preliminarily reviewed?', f'{ans[2]}', '',
394395
'4. is this parent or legal guardian a foreign national here with a visa eligible to',
395396
'domicile in the United States or are you a Refugee, Asylee, Parolee or here under',
396-
'Temporary Protective Status? If so, indicate which:', '',
397-
'5. Does this parent or legal guardian currently live in Texas?', '',
397+
'Temporary Protective Status? If so, indicate which:', f'{ans[3]}', '',
398+
'5. Does this parent or legal guardian currently live in Texas?', f'{ans[4]}', '',
398399
'6. If your parent or legal guardian currently live in Texas:', '',
399-
'(a) How long has he or she been living here?', '',
400-
"(b) What is your parent's or legal guardian's main purpose for being in the state?", '',
401-
'7. If your parent or legal guardian is a member of the U.S. military:',
402-
'(a) Is Texas his or her Home of Record?', '',
400+
'(a) How long has he or she been living here?', f'{ans[5]}', '',
401+
"(b) What is your parent's or legal guardian's main purpose for being in the state?", f'{ans[6]}', '',
402+
'7. If your parent or legal guardian is a member of the U.S. military:', '',
403+
'(a) Is Texas his or her Home of Record?', f'{ans[7]}', '',
403404
'(b) What state is listed as his or her military legal residence for tax purposes on his or',
404-
'her Leave and Earnings Statement?', '',
405-
'8. Do any of the following apply ot your parent or legal guardian?',
405+
'her Leave and Earnings Statement?', f'{ans[8]}', '',
406+
'8. Do any of the following apply ot your parent or legal guardian?', '',
406407
'(a) Does your parent or legal guardian hold the title (Warranty Deed, Deed of Trust, or',
407408
'other similar instrument that is effective to hold title) to residential real property in',
408-
'Texas?', '',
409+
'Texas?', f'{ans[9]}', '',
409410
'(b) Does your parent or legal guardian have ownership interest and customarily manage a',
410-
'business in Texas without the intention of liquidation in the foreseeable future?', '',
411-
'9. For the past 12 months',
412-
'(a) Has your parent or legal guardian been gainfully employed in Texas?', '',
411+
'business in Texas without the intention of liquidation in the foreseeable future?', f'{ans[10]}', '',
412+
'9. For the past 12 months', '',
413+
'(a) Has your parent or legal guardian been gainfully employed in Texas?', f'{ans[11]}', '',
413414
'(b) Has your parent or legal guardian received primary support from a social service',
414-
'agency?', "",
415+
'agency?', f'{ans[12]}', '',
415416
'10. Is your parent or legal guardian married to a person who could claim "yes" to any part',
416-
'of question (8) or (9)?', '',
417+
'of question (8) or (9)?', f'{ans[13]}', '',
417418
'(a) If yes, indicate which question could be answered "yes" by your parent or legal',
418-
"guardian's spouse:", '',
419-
'(b) How long has your parent or legal guardian been married to the Texas Resident?', '',
419+
"guardian's spouse:", f'{ans[14]}', '',
420+
'(b) How long has your parent or legal guardian been married to the Texas Resident?', f'{ans[15]}',
420421
]
421422

main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ def run(file: str, fileName: str) -> None:
161161
# run(file, fileName)
162162

163163
file, fileName = find_spe_file()
164-
run_target(file, fileName, 'domestic', 8) #0306240a
164+
run_target(file, fileName, 'domestic', 24) #0102240a, size 11
165+
166+
# file, fileName = find_spe_file()
167+
# run_target(file, fileName, 'domestic', 6) #0102240a, size 5
168+
169+
# file, fileName = find_spe_file()
170+
# run_target(file, fileName, 'domestic', 29) #0102240a, size 4
165171

166172
# filePath_list, fileName_list = find_spe_folder_files()
167173
# for idx in range(len(filePath_list)):

0 commit comments

Comments
 (0)