From 940754fff2ec22c374f719ca0df0873e72034b31 Mon Sep 17 00:00:00 2001 From: Nick-prog Date: Wed, 26 Jun 2024 15:37:43 -0500 Subject: [PATCH] Updated structure and syntax Added necessary documentation to both files and changed some of the outputs in structure.py to fit with current application explanations. --- core/structure.py | 195 +++++++++++++++++++++++++++++++++++++--------- core/syntax.py | 117 +++++++++++++++++++++++++++- 2 files changed, 275 insertions(+), 37 deletions(-) diff --git a/core/structure.py b/core/structure.py index 9f805b3..327c7bc 100644 --- a/core/structure.py +++ b/core/structure.py @@ -3,6 +3,16 @@ class Structure: def __init__(self, _list: list, idx: int): + """Structure Class handles all methods related to initially translating markdown text into a readable + format. Several class list are initialized for the purpose of holding final (self.output) and current + (self.markdown) translations, as well as, tracking line by line inputs (self.target). Class variables + hold a check flag for later return separations and student name capturing. + + :param _list: list of lines captured from the selected .spe file + :type _list: list + :param idx: current nested list's idx + :type idx: int + """ self._list = _list self.idx = idx @@ -27,6 +37,15 @@ def __init__(self, _list: list, idx: int): self.res_comments_check = 0 def error_handler(self, markdown: str, text: str) -> None: + """Class error handler for missing translations found at any given + method. + + :param markdown: Method's designated markdown translation + :type markdown: str + :param text: flag indicator to invoke ReferenceError + :type text: str + :raises ReferenceError: Returns the method along with the inputted line and student name where error occurrd. + """ if text == 'Other': r = core.Report([self.output]) @@ -34,6 +53,12 @@ def error_handler(self, markdown: str, text: str) -> None: raise ReferenceError(f'{markdown} translation missing in structure: {self.target}, {self.idx}, {r.student_name}') def translate(self) -> list: + """Main method created to handle translation distrubtion amongst the rest of the created + methods. + + :return: final list of translated values + :rtype: list + """ for idx, item in enumerate(self._list): self.target = str(item).split('!') @@ -83,6 +108,11 @@ def translate(self) -> list: return self.output def translate_ATV(self) -> list: + """Method for ATV markdown text: EXtra Curricular, Community, Employment, and Honor information. + + :return: translated list + :rtype: list + """ if self.target[0] != 'ATV': return @@ -109,6 +139,11 @@ def translate_ATV(self) -> list: return _list def translate_COM(self) -> str: + """Method for COM markdown text: Email and Phone information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'COM': return @@ -149,6 +184,11 @@ def translate_COM(self) -> str: return f'{trans_prefix}: {sep}' def translate_CRS(self) -> str: + """Method for CRS markdown text: Course information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'CRS': return @@ -179,6 +219,11 @@ def translate_CRS(self) -> str: return _list def translate_DEG(self) -> str: + """Method for DEG markdown text: Previous Degree and Major information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'DEG': return @@ -202,6 +247,11 @@ def translate_DEG(self) -> str: return f'{translate} {self.target[-1]}' def translate_DMG(self) -> str: + """Method for DMG markdown text: Date of Birth and Gender information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'DMG': return @@ -222,6 +272,11 @@ def translate_DMG(self) -> str: return f'Date of Birth: {dob} Gender={gender}' def translate_DTP(self) -> str: + """Method for DTP markdown text: Date and Time information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'DTP': return @@ -244,6 +299,11 @@ def translate_DTP(self) -> str: return f'{sep}: {date[4:6]}-{date[:4]}' def translate_FOS(self) -> str: + """Method for FOS markdown text: Application Major and Interest information. + + :return: translated string [moves Major up for clearer presentation] + :rtype: str + """ if self.target[0] != 'FOS': return @@ -262,6 +322,13 @@ def translate_FOS(self) -> str: return f'{sep}: {self.target[-1]}' def translate_IN1(self, idx: int) -> list: + """Method for IN1 markdown text: Student and Emergency Contact information. + + :param idx:: current idx [for later student name capturing] + :param type: int + :return: translated list + :rtype: list + """ if self.target[0] != 'IN1': return @@ -283,15 +350,22 @@ def translate_IN1(self, idx: int) -> list: '': '' } - parent = _translate.get(self.target[3], "Other") - self.error_handler('IN1', parent) + contact_type = _translate.get(self.target[3], "Other") + self.error_handler('IN1', contact_type) - if parent == '': + if contact_type == '': + if int(self.target[-1]) < 30 and contact != 'Student Contact:': + return ['', f'{contact} Child {int(self.target[-1])}'] return ['', f'{contact}'] else: - return ['', f'{contact} {parent}'] + return ['', f'{contact} {contact_type}'] def translate_IN2(self) -> str: + """Method for IN2 markdown text: Name information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'IN2': return @@ -316,6 +390,11 @@ def translate_IN2(self) -> str: return def translate_IND(self) -> str: + """Method for IND markdown text: Place of Birth and Country/City information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'IND': return @@ -328,24 +407,13 @@ def translate_IND(self) -> str: pob = ' '.join(pob) return f'Place of Birth: {pob[:2]}, Country/City: {pob[2:]}' - - def translate_MSG(self) -> str: - - if self.target[0] != 'MSG': - return - - _translate = { - 'AT\\': 'paragraph', - 'DS\\': 'answer', - } - - if self.target[-1] in _translate: - return f'{self.target[-2]}' - else: - address = str(self.target[-1]).replace('\\', '') - return f'{address}' def translate_N1(self) -> str: + """Method for N1 markdown text: Header or Subject Text information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'N1': return @@ -369,6 +437,11 @@ def translate_N1(self) -> str: return f'{sep}' def translate_N3_N4(self) -> str: + """Method for N3 and N4 markdown text: Address information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'N3' and self.target[0] != 'N4': return @@ -392,6 +465,11 @@ def translate_N3_N4(self) -> str: return f'Secondary Address: {address}' def translate_NTE(self) -> list: + """Method for NTE markdown text: Ethnicity and Race information. + + :return: translated list + :rtype: list + """ if self.target[0] != 'NTE': return @@ -411,8 +489,7 @@ def translate_NTE(self) -> list: 'V': 'Native Hawaiian or Other Pacific Islander' } - ethnicity[-1] = _translate.get(ethnicity[-1], "Other") - self.error_handler('NTE', ethnicity[-1]) + ethnicity[-1] = _translate.get(ethnicity[-1], ethnicity) if len(split) == 1: return [f'{ethnicity[0]}={ethnicity[-1]}.'] @@ -441,6 +518,11 @@ def translate_NTE(self) -> list: return [f'{ethnicity[0]}={ethnicity[-1]}.', f'{race[0]}={race[-1]}'] def translate_PCL(self) -> list: + """Method for PCL markdown text: College information. + + :return: translated list + :rtype: list + """ if self.target[0] != 'PCL': return @@ -464,6 +546,11 @@ def translate_PCL(self) -> list: f'Dates Attended: {dates}'] def translate_REF(self) -> str: + """Method for REF markdown text: Important Person/App Specific information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'REF': return @@ -497,6 +584,11 @@ def translate_REF(self) -> str: return f'{ref}: {self.target[2]}| {app}' def translate_RQS(self) -> list: + """Method for RQS markdown text: Sevearl Unique Reqeust/Answer type information. + + :return: translated list + :rtype: list + """ if self.target[0] != 'RQS': return @@ -526,14 +618,20 @@ def translate_RQS(self) -> list: return [self.target[-1], ''] if self.target[3] == 'RES: COMMENTS': + if self.target[-1] == 'RES: COMMENTS': + self.res_comments_check = 1 + return ['General Comments:', + 'Is there any additional information that you believe your college should know in', + 'evaluating your eligibility to be classified as a resident? If so, please provide it', + 'below.'] if self.res_comments_check == 0: self.res_comments_check = 1 return ['General Comments:', 'Is there any additional information that you believe your college should know in', 'evaluating your eligibility to be classified as a resident? If so, please provide it', - 'below.', - self.target[-1], ''] - return [self.target[-1], ''] + 'below.', + self.target[-1]] + return [self.target[-1]] basic_output = s._syntax.get(self.target[-1], self.target[-1]) @@ -627,15 +725,18 @@ def translate_RQS(self) -> list: return output def translate_MSG(self) -> list: + """Method for MSG markdown text: Several Short Message information. + + :return: translated list + :rtype: list + """ if self.target[0] != 'MSG': return - - _str = str(self.target[-1]).replace('\\', '') _list = [] - if _str in ['AT', 'DS']: + if self.target[-1] in ['AT', 'DS']: for idx, items in enumerate(self.target): if idx != 0 and idx != len(self.target)-1: _list.append(items) @@ -643,15 +744,15 @@ def translate_MSG(self) -> list: if len(items) <= 3: _list.append('') elif len(self.target) == 2 and len(self.target[1]) <= 31: - if (_str != 'NO RESIDENCY COMMENTS INCLUDED'): + if (self.target[-1] != 'NO RESIDENCY COMMENTS INCLUDED'): s = core.Syntax(None) - _list.append(s._syntax.get(_str, _str)) + _list.append(s._syntax.get(self.target[-1] , self.target[-1] )) _list.append('') else: temp = '' prev_char = [0, 0] - for idx, char in enumerate(_str): + for idx, char in enumerate(self.target[-1] ): temp += char prev_char[idx%2] = char @@ -660,11 +761,8 @@ def translate_MSG(self) -> list: _list.append(str(temp).strip()) temp = '' - # if temp: - # if self.general_comments_check == 0: - # self.general_comments_check = 1 - # return ['General Comments:', self.target[-1]] - # return [self.target[-1]] + if temp: + return [self.target[-1], ''] _list.insert(0, '9. Mailing/Permanent Address:') _list.append('') @@ -672,6 +770,11 @@ def translate_MSG(self) -> list: return _list def translate_SES(self) -> str: + """Method for SES markdown text: Specific Date Formatting or Degree information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'SES': return @@ -689,6 +792,11 @@ def translate_SES(self) -> str: return f'Date: {date}, Degree: {self.target[-1]}' def translate_SSE(self) -> str: + """Method for SSE markdown text: Semester and Date information. + + :return: translated string [moved Semester info up for better structure] + :rtype: str + """ if self.target[0] != 'SSE': return @@ -710,6 +818,11 @@ def translate_SSE(self) -> str: return f'(Attendance dates: {self.target[1][4:6]}/{self.target[1][:4]} - {self.target[2][4:6]}/{self.target[2][:4]})' def translate_SST(self) -> list: + """Method for SST markdown text: Graduation Date information. + + :return: translated list + :rtype: lisr + """ if self.target[0] != 'SST': return @@ -720,6 +833,11 @@ def translate_SST(self) -> list: return ['Expected Graduation Date:', f'{self.target[-1][4:]}/{self.target[-1][:4]}', ''] def translate_SUM(self) -> str: + """Method for SUM markdown text: Hours Earned information. + + :return: translated string + :rtype: str + """ if self.target[0] != 'SUM': return @@ -727,6 +845,11 @@ def translate_SUM(self) -> str: return f'Hours Earned {self.target[-1]}' def translate_TST(self) -> list: + """Method for TST markdown text: Test (ACT/SAT) information. + + :return: translated list + :rtype: list + """ if self.target[0] != 'TST': return diff --git a/core/syntax.py b/core/syntax.py index 430df09..f79fade 100644 --- a/core/syntax.py +++ b/core/syntax.py @@ -3,6 +3,13 @@ class Syntax: def __init__(self, target: list): + """Syntax class handles more in-depth translations that require more decoupling to make a clearer + explanation typically for RQS markdown text. A _syntax dict is created to hold general translations + for most method self.target lines. + + :param target: current line for translation + :type target: list + """ self.target = target self._syntax = { @@ -14,6 +21,12 @@ def __init__(self, target: list): } def PRE_PROFESSIONAL(self) -> list: + """PRE PROFESSIONAL text for the markdown RQS. Contains information for the + preprofessional program question. + + :return: tranlasted list + :rtype: list + """ _list = core.Process().process_str_with_blank(self.target[3]) @@ -31,6 +44,12 @@ def PRE_PROFESSIONAL(self) -> list: return ['Do you plan to pursue a preprofessional program?', f'{_syntax.get(_list[1], _list[1])}', ''] def CERT_SWITCH(self) -> list: + """CERT SWITCH text for the markdown RQS. Contains information for the + certification statements. + + :return: tranlasted list + :rtype: list + """ _syntax = { 'FERPA CERT SWITCH': 'FERPA certification box checked on', @@ -54,6 +73,12 @@ def CERT_SWITCH(self) -> list: return output def CONSERVATORSHIP_SWITCHES(self) -> list: + """CONSERVATORSHIP SWITCHES text for the markdown RQS. Contains information for the + conservatorship question. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'CONSERVATORSHIP SWITCHES': return @@ -72,6 +97,12 @@ def CONSERVATORSHIP_SWITCHES(self) -> list: f'{second}', ''] def HS_GED_TYPE(self) -> list: + """HS GED TYPE text for the markdown RQS. Contains information for the + high school equivalency program question. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'HS GED TYPE': return @@ -85,6 +116,12 @@ def HS_GED_TYPE(self) -> list: f'{target}-{final}', ''] def COLLEGE_WORK(self) -> list: + """COLLEGE WORK text for the markdown RQS. Contains information for the + college credit hour question. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'COLLEGE WORK': return @@ -100,6 +137,12 @@ def COLLEGE_WORK(self) -> list: f'{self.target[-1]}', ''] def RES_PREVIOUS_ENROLLMENT(self) -> list: + """RES PREVIOUS ENROLLMENT text for the markdown RQS. Contains information for the + residency question: previous enrollment. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'RES: PREVIOUS ENROLLMENT': return @@ -143,6 +186,12 @@ def RES_PREVIOUS_ENROLLMENT(self) -> list: 'for a public college or university in Texas?', f'{self._syntax.get(self.target[-1][0], self.target[-1][0])}', ''] def RES_BASIS_OF_CLAIM(self) -> list: + """RES BASIS OF CLIAM text for the markdown RQS. Contains information for the + residcency question: basis of claim. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'RES: BASIS OF CLAIM': return @@ -167,6 +216,12 @@ def RES_BASIS_OF_CLAIM(self) -> list: 'by a parent or court-appointed legal guardian?', f'{self._syntax.get(self.target[-1][1], self.target[-1][1])}', ''] def RES_DETERM(self) -> list: + """RES DETERM text for the markdown RQS. Contains information for the + residency question: determination. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'RES: DETERM': return @@ -190,17 +245,29 @@ def RES_DETERM(self) -> list: f'Applytexas Residency Determination: {_syntax.get(self.target[-1], "U - Unable to determine")}', ''] def RES_HS_DIPLOMA_OR_GED(self) -> list: + """RES HS DIPLOMA OR GED text for the markdown RQS. Contains information for the + residency question: high school name and graduation. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'RES: HS DIPLOMA OR GED': return - return [f'Previous High School Name: {self.target[-1][:-2]}', + return [f'Previous High School Name: {self.target[-1][:-2]}','', 'Did you live or will you have lived in Texas the 36 months leading up', 'to high school graduation or completion of the GED?', f'{self._syntax.get(self.target[-1][-2:][0], self.target[-1][-2:][0])}', '', 'When you begin the semester for which you are applying, will you have lived', 'in Texas for the previous 12 months?', f'{self._syntax.get(self.target[-1][-2:][1], self.target[-1][-2:][1])}', ''] def RES_RESIDENCY_CLAIM(self) -> list: + """RES RESIDENCY CLAIM text for the markdown RQS. Contains information for the + residency question: state/country claim. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'RES: RESIDENCY CLAIM': return @@ -210,6 +277,12 @@ def RES_RESIDENCY_CLAIM(self) -> list: f'{self.target[-2]}--{self.target[-1]}', ''] def RES_SELF(self) -> list: + """RES SELF text for the markdown RQS. Contains information for the + residency question: self indicated. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'RES: SELF': return @@ -278,6 +351,12 @@ def RES_SELF(self) -> list: f'{_list[33]}{_list[34]} Years {_list[35]}{_list[36]} Months', ''] def RES_GUAR(self) -> list: + """RES GUAR text for the markdown RQS. Contains information for the + residency question: parent or guardian indicated. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'RES: GUAR': return @@ -336,6 +415,12 @@ def RES_GUAR(self) -> list: '(b) How long has your parent or legal guardian been married to the Texas Resident?', f'{_list[71]}{_list[72]} Months; {_list[69]}{_list[70]} Years', ''] def FORMER_STUDENT(self) -> list: + """FORMER STUDENT text for the markdown RQS. Contains information for the + previous student question. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'FORMER STUDENT': return @@ -346,6 +431,12 @@ def FORMER_STUDENT(self) -> list: f'{self._syntax.get(self.target[-1][-1], self.target[-1][-1])}', ''] def ULTIMATE_DEGREE_SOUGHT(self) -> list: + """ULTIMATE DEGREE SOUGHT text for the markdown RQS. Contains information for the + degree goal question. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'ULTIMATE DEGREE SOUGHT': return @@ -358,6 +449,12 @@ def ULTIMATE_DEGREE_SOUGHT(self) -> list: return ['Ultimate Degree Sought:', f'{_syntax.get(self.target[-1], self.target[-1])}', ''] def CTRY_SELF(self) -> list: + """CTRY SELF text for the markdown RQS. Contains information for the + citizen residence question. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'CTRY SELF': return @@ -372,6 +469,12 @@ def CTRY_SELF(self) -> list: f'Country of legal Permanent Residence: {_list[1]}', ''] def PAYMENT_RECONCILIATION(self) -> list: + """PAYMENT RECONILATION text for the markdown RQS. Contains information for the + application fee information. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'PAYMENT RECONCILIATION': return @@ -389,6 +492,12 @@ def PAYMENT_RECONCILIATION(self) -> list: f"Card Expiration Date: {target[53:55]}/{target[55:57]}", ''] def VET_STATUS(self) -> list: + """VET STATUS text for the markdown RQS. Contains information for the + veteran infomration. + + :return: tranlasted list + :rtype: list + """ if self.target[3] != 'VET STATUS': return @@ -414,6 +523,12 @@ def VET_STATUS(self) -> list: return _list.append('') def OTHER_NAME(self) -> list: + """OTHER NAME text for the markdown RQS. Contains information for the + other names listed. + + :return: tranlasted list + :rtype: list + """ if len(self.target) != 6: return