From b72752c470906dfaadda4eb099cb3b3ff8cdb19f Mon Sep 17 00:00:00 2001 From: "Michael DeMichillie (First Information Technology)" Date: Mon, 24 Feb 2020 16:28:08 -0800 Subject: [PATCH 1/5] Added handling for checkbox characters in origination/implementation --- ssp/control.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ssp/control.py b/ssp/control.py index 751a1d8..16ebea2 100644 --- a/ssp/control.py +++ b/ssp/control.py @@ -109,6 +109,18 @@ def get_implementation_status(self, cell): self.implementation_status.append('Alternative Implementation') elif 'Not' in implementation_status: self.implementation_status.append('Not Applicable') + elif '☒' in paragraph.text: + implementation_status = paragraph.text.strip() + if 'Partially' in implementation_status: + self.implementation_status.append('Partially Implemented') + elif 'Implemented' in implementation_status: + self.implementation_status.append('Implemented') + elif 'Planned' in implementation_status: + self.implementation_status.append('Planned') + elif 'Alternative' in implementation_status: + self.implementation_status.append('Alternative Implementation') + elif 'Not' in implementation_status: + self.implementation_status.append('Not Applicable') def get_control_origination(self, cell): """ @@ -156,3 +168,21 @@ def get_control_origination(self, cell): self.control_origination.append("Inherited") elif "Not" in control_origination: self.control_origination.append("Not Applicable") + elif '☒' in paragraph.text: + control_origination = paragraph.text.strip() + if "Service Provider Corporate" in control_origination: + self.control_origination.append("Service Provider Corporate") + elif "Service Provider System Specific" in control_origination: + self.control_origination.append("Service Provider System Specific") + elif "Hybrid" in control_origination: + self.control_origination.append("Service Provider Hybrid") + elif "Configured" in control_origination: + self.control_origination.append("Configured by Customer") + elif "Provided" in control_origination: + self.control_origination.append("Provided by Customer") + elif "Shared" in control_origination: + self.control_origination.append("Shared") + elif "Inherited" in control_origination: + self.control_origination.append("Inherited") + elif "Not" in control_origination: + self.control_origination.append("Not Applicable") \ No newline at end of file From 874dc0b802483386e82153cb63264f5118a471fb Mon Sep 17 00:00:00 2001 From: "Michael DeMichillie (First Information Technology)" Date: Wed, 26 Feb 2020 09:56:46 -0800 Subject: [PATCH 2/5] control parts capture Ext in main SSP --- ssp/control.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ssp/control.py b/ssp/control.py index 16ebea2..208716b 100644 --- a/ssp/control.py +++ b/ssp/control.py @@ -33,6 +33,8 @@ def get_parts(self): self.parts.append(row.cells[0].text.replace('Part ', '').strip()) elif 'Req.' in row.cells[0].text and len(row.cells[0].text) < 8: self.parts.append(row.cells[0].text.replace('Req. ', '').strip()) + elif 'Ext.' in row.cells[0].text and len(row.cells[0].text) < 8: + self.parts.append(row.cells[0].text.strip()) if len(self.parts) < 1 and len(self.implementation_table.rows) < 3: self.parts.append(None) @@ -185,4 +187,9 @@ def get_control_origination(self, cell): elif "Inherited" in control_origination: self.control_origination.append("Inherited") elif "Not" in control_origination: - self.control_origination.append("Not Applicable") \ No newline at end of file + self.control_origination.append("Not Applicable") + +#class Part(): + #def __init__(self, id, implementation): + #self.id = id + #self.implementation = implementation \ No newline at end of file From f95730d4bcbf9aede1e8ee845f4d9905c63f47dd Mon Sep 17 00:00:00 2001 From: "Michael DeMichillie (First Information Technology)" Date: Wed, 26 Feb 2020 10:06:02 -0800 Subject: [PATCH 3/5] added handling single-part controls --- ssp/control.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ssp/control.py b/ssp/control.py index 208716b..19006cc 100644 --- a/ssp/control.py +++ b/ssp/control.py @@ -35,6 +35,8 @@ def get_parts(self): self.parts.append(row.cells[0].text.replace('Req. ', '').strip()) elif 'Ext.' in row.cells[0].text and len(row.cells[0].text) < 8: self.parts.append(row.cells[0].text.strip()) + elif bool(re.match(r'\w+-\d',row.cells[0].text)): + self.parts.append('Main') if len(self.parts) < 1 and len(self.implementation_table.rows) < 3: self.parts.append(None) @@ -48,6 +50,11 @@ def part(self, part_id): return self.implementation_table.cell(1,0) except IndexError: raise IndexError('Control table %s does not have enough rows to contain a control response.' % (self.number)) + elif part_id.upper() == 'Main'.upper(): + try: + return self.implementation_table.cell(1,1) + except IndexError: + raise IndexError('Control table %s does not have enough rows to contain a control response.' % (self.number)) if part_id in self.parts: split_alpha_part = re.compile(r'\w\d') From 74816edd717470d2410fd1d4aa6052abf5a2e70f Mon Sep 17 00:00:00 2001 From: "Michael DeMichillie (First Information Technology)" Date: Wed, 26 Feb 2020 14:37:47 -0800 Subject: [PATCH 4/5] Fixed handling for single-part controls with exts --- ssp/control.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ssp/control.py b/ssp/control.py index 19006cc..f5521d0 100644 --- a/ssp/control.py +++ b/ssp/control.py @@ -28,6 +28,8 @@ def __iter__(self): def get_parts(self): self.parts = [] + if bool(re.match(r'\w+-\d',self.implementation_table.cell(1,0).text)): + self.parts.append('Main') for row in self.implementation_table.rows: if "Part" in row.cells[0].text and len(row.cells[0].text) < 8: self.parts.append(row.cells[0].text.replace('Part ', '').strip()) @@ -35,8 +37,7 @@ def get_parts(self): self.parts.append(row.cells[0].text.replace('Req. ', '').strip()) elif 'Ext.' in row.cells[0].text and len(row.cells[0].text) < 8: self.parts.append(row.cells[0].text.strip()) - elif bool(re.match(r'\w+-\d',row.cells[0].text)): - self.parts.append('Main') + if len(self.parts) < 1 and len(self.implementation_table.rows) < 3: self.parts.append(None) @@ -65,6 +66,12 @@ def part(self, part_id): return self.implementation_table.cell(self.LETTERS[letter]+row_difference, 1) except: ValueError('Control does not have part ' + part_id) + elif bool(re.match(r'\w{3,}', part_id)): + try: + row = [cell.text.strip() for cell in self.implementation_table.columns[0].cells].index(part_id) + return self.implementation_table.cell(row, 1) + except ValueError: + raise ValueError('Control does not have part ' + part_id) else: try: return self.implementation_table.cell(self.LETTERS[part_id], 1) From efee9057130d519550b65051440881c4453e40e3 Mon Sep 17 00:00:00 2001 From: Michael DeMichillie Date: Tue, 2 Nov 2021 09:59:40 -0700 Subject: [PATCH 5/5] xpath logic now catches inheritance --- ssp/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ssp/control.py b/ssp/control.py index f5521d0..77e4d5f 100644 --- a/ssp/control.py +++ b/ssp/control.py @@ -147,9 +147,9 @@ def get_control_origination(self, cell): p = paragraph._element if 'w14:checked w14:val="1"' in p.xml: xpath_elements = p.xpath('.//w:t') - control_origination = xpath_elements[len(xpath_elements)-1].text.strip() - if not control_origination: - control_origination = xpath_elements[len(xpath_elements)-2].text.strip() #TODO: this is really ugly, but had to be done because inherited checkboxes werent being captured. + for text in [element.text.strip() for element in xpath_elements]: + if any(origination in text for origination in ['Service Provider', 'Inherited', 'Not', 'Customer']): + control_origination = xpath_elements[1].text.strip() if "Service Provider Corporate" in control_origination: self.control_origination.append("Service Provider Corporate") elif "Service Provider System Specific" in control_origination: