Skip to content

Commit

Permalink
Moved preface xpath to subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessioNar committed Dec 27, 2024
1 parent 88a5a5c commit 213b002
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/parsers/test_akomantoso.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_get_root(self):

def test_get_preface(self):
"""Test the content extracted from the preface section."""
self.parser.get_preface(preface_xpath='.//akn:preface', paragraph_xpath='.//akn:p')
self.parser.get_preface()
self.assertIsNotNone(self.parser.preface, "Preface element not found")

expected_preface = "Directive 2014/92/EU of the European Parliament and of the Council of 23 July 2014 on the comparability of fees related to payment accounts, payment account switching and access to payment accounts with basic features (Text with EEA relevance)"
Expand Down
2 changes: 1 addition & 1 deletion tests/parsers/test_formex.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_get_preface(self):
self.maxDiff = None # Allow full diff if needed


self.parser.get_preface(preface_xpath='.//TITLE', paragraph_xpath='.//P')
self.parser.get_preface()
expected = (
"Commission Implementing Regulation (EU) No 1319/2011 of 15 December 2011 "
"fixing representative prices in the poultrymeat and egg sectors and for egg "
Expand Down
5 changes: 4 additions & 1 deletion tulit/parsers/akomantoso.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def __init__(self):
'fmx': 'http://formex.publications.europa.eu/schema/formex-05.56-20160701.xd'

}


def get_preface(self):
return super().get_preface(preface_xpath='.//akn:preface', paragraph_xpath='.//akn:p')

def get_formula(self):
"""
Extracts formula text from the preamble.
Expand Down
7 changes: 5 additions & 2 deletions tulit/parsers/formex.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def __init__(self):
self.namespaces = {
'fmx': 'http://formex.publications.europa.eu/schema/formex-05.56-20160701.xd'
}


def get_preface(self):
return super().get_preface(preface_xpath='.//TITLE', paragraph_xpath='.//P')

def get_formula(self):
"""
Extracts the formula from the preamble.
Expand Down Expand Up @@ -161,7 +164,7 @@ def parse(self, file):
self.validate(file, format = 'Formex 4')
self.get_root(file)
self.get_metadata()
self.get_preface(preface_xpath='.//TITLE', paragraph_xpath='.//P')
self.get_preface()
self.get_preamble(preamble_xpath='.//PREAMBLE', notes_xpath='.//NOTE')
self.get_body()
self.get_chapters()
Expand Down

0 comments on commit 213b002

Please sign in to comment.