From cbf1c1772df29413bd29541a03fd650f17c7fede Mon Sep 17 00:00:00 2001 From: AlessioNar Date: Sat, 28 Dec 2024 16:10:44 +0100 Subject: [PATCH] Fixed preamble.final element --- tulit/parsers/akomantoso.py | 5 +---- tulit/parsers/formex.py | 13 +------------ tulit/parsers/parser.py | 12 ++---------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/tulit/parsers/akomantoso.py b/tulit/parsers/akomantoso.py index 81b1e05..27a4a44 100644 --- a/tulit/parsers/akomantoso.py +++ b/tulit/parsers/akomantoso.py @@ -108,11 +108,8 @@ def get_preamble_final(self): Concatenated text from the final preamble element. Returns None if no final preamble is found. """ - preamble_final = self.preamble.find(".//akn:block", namespaces=self.namespaces).text - self.preamble_final = preamble_final - return self.preamble_final + return super().get_preamble_final(preamble_final_xpath='.//akn:block[@name="preamble.final"]') - #return super().get_preamble_final(preamble_final_xpath='.//block[@name="preamble.final"]') def get_body(self): return super().get_body('.//akn:body') diff --git a/tulit/parsers/formex.py b/tulit/parsers/formex.py index 05fb2d5..9d1db42 100644 --- a/tulit/parsers/formex.py +++ b/tulit/parsers/formex.py @@ -100,18 +100,7 @@ def extract_eId(recital): ) def get_preamble_final(self): - """ - Extracts the final preamble text from the document. - - Returns - ------- - str or None - Concatenated text from the final preamble element. - Returns None if no final preamble is found. - """ - self.preamble_final = self.preamble.findtext('PREAMBLE.FINAL') - - return self.preamble_final + return super().get_preamble_final(preamble_final_xpath='.//PREAMBLE.FINAL') def get_body(self): return super().get_body('.//ENACTING.TERMS') diff --git a/tulit/parsers/parser.py b/tulit/parsers/parser.py index 7fef2c0..45a1281 100644 --- a/tulit/parsers/parser.py +++ b/tulit/parsers/parser.py @@ -356,25 +356,17 @@ def get_recitals(self, recitals_xpath, recital_xpath, text_xpath, extract_intro= self.recitals = recitals - def get_preamble_final(self) -> str: + def get_preamble_final(self, preamble_final_xpath) -> str: """ Extracts the final preamble text from the document. - Parameters - ---------- - preamble_final_xpath : str - XPath expression to locate the final preamble element. - Returns ------- str or None Concatenated text from the final preamble element. Returns None if no final preamble is found. """ - preamble_final = self.preamble.findtext('.//block', namespaces=self.namespaces) - if preamble_final is None: - return None - + preamble_final = self.preamble.findtext(preamble_final_xpath, namespaces=self.namespaces) self.preamble_final = preamble_final return self.preamble_final