Skip to content

Commit 9888bcb

Browse files
committed
Improve handling around converters.
1 parent 1d2922f commit 9888bcb

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

PyFunceble/converter/input_line2subject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
class InputLine2Subject(ConverterBase):
6262
"""
63-
Converts/Extract the subjcts to test from an inputed line.
63+
Converts/Extract the subjects to test from an imputed line.
6464
"""
6565

6666
COMMENT: str = "#"
@@ -72,7 +72,7 @@ class InputLine2Subject(ConverterBase):
7272
@ConverterBase.data_to_convert.setter
7373
def data_to_convert(self, value: Any) -> None:
7474
"""
75-
Overrites the default behavior.
75+
Overrides the default behavior.
7676
7777
:raise TypeError:
7878
When the given data to convert is not :py:class:`str`

PyFunceble/converter/internal_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class InternalUrlConverter(ConverterBase):
7171
@ConverterBase.data_to_convert.setter
7272
def data_to_convert(self, value: Any) -> None:
7373
"""
74-
Overrites the default behavior.
74+
Overrides the default behavior.
7575
7676
:raise TypeError:
7777
When the given data to convert is not :py:class:`str`

PyFunceble/converter/rpz_input_line2subject.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
class RPZInputLine2Subject(InputLine2Subject):
6161
"""
62-
Converts/Extracts the subject from the given RPZ inputline.
62+
Converts/Extracts the subject from the given RPZ input line.
6363
"""
6464

6565
COMMENT: list = [";", "//", "#"]
@@ -96,9 +96,7 @@ def convert(self, data: Any, *, aggressive: bool = False) -> List[str]:
9696
if self.SPACE in subject or self.TAB in subject:
9797
subject = subject.split()[0]
9898

99-
if not subject.isdigit():
100-
result.append(subject)
101-
elif not subject.isdigit():
99+
if not subject.isdigit():
102100
result.append(subject)
103101

104102
return result

PyFunceble/converter/subject2complements.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Subject2Complements(ConverterBase):
6464
"""
6565

6666
_include_given: bool = False
67+
domain_syntax_checker: Optional[DomainSyntaxChecker] = None
6768

6869
def __init__(
6970
self,
@@ -74,6 +75,8 @@ def __init__(
7475
if include_given is not None:
7576
self.include_given = include_given
7677

78+
self.domain_syntax_checker = DomainSyntaxChecker()
79+
7780
super().__init__(data_to_convert=data_to_convert)
7881

7982
@ConverterBase.data_to_convert.setter
@@ -143,7 +146,7 @@ def convert(self, data: Any, *, aggressive: bool = False) -> List[str]:
143146
_ = aggressive
144147
result = []
145148

146-
checker = DomainSyntaxChecker(data)
149+
checker = self.domain_syntax_checker.set_subject(data)
147150

148151
if self.include_given and data not in result:
149152
result.append(data)

PyFunceble/converter/url2netloc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
class Url2Netloc(ConverterBase):
6060
"""
61-
Provides the interface for the conversion/extration of the network location
61+
Provides the interface for the conversion/extraction of the network location
6262
of a given URL.
6363
"""
6464

@@ -70,7 +70,7 @@ class Url2Netloc(ConverterBase):
7070
@ConverterBase.data_to_convert.setter
7171
def data_to_convert(self, value: Any) -> None:
7272
"""
73-
Overrites the default behavior.
73+
Overrides the default behavior.
7474
7575
:raise TypeError:
7676
When the given data to convert is not :py:class:`str`
@@ -116,7 +116,7 @@ def get_converted(self) -> str:
116116
Provides the converted data (after conversion)
117117
"""
118118

119-
# Retrocompatibility.
119+
# Retro-compatibility.
120120
self.parse_url()
121121

122122
return self.convert(self.data_to_convert)

PyFunceble/converter/wildcard2subject.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"""
5353
# pylint: enable=line-too-long
5454

55-
from typing import Any
55+
from typing import Any, Optional
5656

5757
from PyFunceble.converter.base import ConverterBase
5858

@@ -67,7 +67,7 @@ class Wildcard2Subject(ConverterBase):
6767
@ConverterBase.data_to_convert.setter
6868
def data_to_convert(self, value: Any) -> None:
6969
"""
70-
Overrites the default behavior.
70+
Overrides the default behavior.
7171
7272
:raise TypeError:
7373
When the given data to convert is not :py:class:`str`
@@ -86,7 +86,7 @@ def get_converted(self) -> str:
8686

8787
return self.convert(self.data_to_convert)
8888

89-
def convert(self, data: Any, *, aggressive: bool = False) -> str:
89+
def convert(self, data: Any, *, aggressive: bool = False) -> Optional[str]:
9090
"""
9191
Converts the given dataset.
9292

0 commit comments

Comments
 (0)