Skip to content

Commit

Permalink
ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
awdem committed Nov 18, 2024
1 parent dd92137 commit c07703c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
6 changes: 5 additions & 1 deletion eco_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from eco_parser.core import ParseError
from eco_parser.element_parsers import BodyParser, ElementParserFactory, TableParser
from eco_parser.element_parsers import (
BodyParser,
ElementParserFactory,
TableParser,
)
from eco_parser.parser import EcoParser
11 changes: 8 additions & 3 deletions eco_parser/element_parsers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import abc
from eco_parser.core import NAMESPACES, get_single_element, get_child_text, ParseError
from eco_parser.core import (
NAMESPACES,
get_single_element,
get_child_text,
ParseError,
)


class ElementParser(metaclass=abc.ABCMeta):
Expand All @@ -12,7 +17,6 @@ def parse(self):


class TableParser(ElementParser):

FORMAT_UNKNOWN = 0
FORMAT_STANDARD_TABLE = 1
FORMAT_ONE_ROW_PARA = 2
Expand Down Expand Up @@ -60,7 +64,8 @@ def parse_one_row_table(self, tbody):
for j in range(0, i):
if len(data[j]) != expected_length:
raise ParseError(
"Expected %i elements, found %i" % (expected_length, len(data[j])),
"Expected %i elements, found %i"
% (expected_length, len(data[j])),
0,
)

Expand Down
4 changes: 3 additions & 1 deletion eco_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ def parse(self):
elif re.match(article_pattern, self.url):
return self.parse_article()
else:
raise ParseError("Could not find a suitable parser for %s" % (self.url), 0)
raise ParseError(
"Could not find a suitable parser for %s" % (self.url), 0
)
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def _get_description():
long_description_content_type="text/markdown",
entry_points={"console_scripts": ["eco_parser = eco_parser.__main__:main"]},
install_requires=["lxml", "requests"],
extras_require={"testing": ["coveralls"], "development": ["ruff==0.3.7"],},
extras_require={
"testing": ["coveralls"],
"development": ["ruff==0.3.7"],
},
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
Expand Down
12 changes: 7 additions & 5 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
ONE_ROW_TABLE_INVALID = (
"http://www.legislation.gov.uk/uksi/2016/657/schedule/1/made/data.xml"
)
UNKNOWN_TABLE_FORMAT = (
"http://www.legislation.gov.uk/uksi/no-example-of-this/schedule/1/made/data.xml"
)
UNKNOWN_TABLE_FORMAT = "http://www.legislation.gov.uk/uksi/no-example-of-this/schedule/1/made/data.xml"


# stub parser implementation we can run tests against
Expand Down Expand Up @@ -96,8 +94,12 @@ def test_article_without_table(self):
p = StubParser(ARTICLE_WITHOUT_TABLE)
self.assertSequenceEqual(
[
("The existing wards of the borough of Foo Town are abolished",),
("The borough of Foo Town is divided into 5 wards as follows—",),
(
"The existing wards of the borough of Foo Town are abolished",
),
(
"The borough of Foo Town is divided into 5 wards as follows—",
),
("Crummock & Derwent Valley",),
("St John’s",),
("Warnell",),
Expand Down

0 comments on commit c07703c

Please sign in to comment.