Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into col20
Browse files Browse the repository at this point in the history
  • Loading branch information
funilrys committed Mar 26, 2024
2 parents 1cb8fb3 + 467b8aa commit 3e5494e
Show file tree
Hide file tree
Showing 49 changed files with 176 additions and 82 deletions.
8 changes: 1 addition & 7 deletions PyFunceble/checker/availability/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
from PyFunceble.checker.syntax.ip import IPSyntaxChecker
from PyFunceble.checker.syntax.url import URLSyntaxChecker
from PyFunceble.converter.url2netloc import Url2Netloc
from PyFunceble.helpers.regex import RegexHelper
from PyFunceble.query.dns.query_tool import DNSQueryTool
from PyFunceble.query.http_status_code import HTTPStatusCode
from PyFunceble.query.netinfo.address import AddressInfo
Expand Down Expand Up @@ -919,12 +918,7 @@ def try_to_query_status_from_http_status_code(
if from_domain_test and self.status.url_syntax:
return self

if not self.status.url_syntax and not RegexHelper("[^a-z0-9._]").match(
self.idna_subject, return_match=False
):
# The regex is there because while testing for domain, sometime we
# may see something like mailto:[email protected]

if not self.status.url_syntax and not self.idna_subject.startswith("http"):
self.http_status_code_query_tool.set_subject(
f"http://{self.idna_subject}:80"
)
Expand Down
1 change: 0 additions & 1 deletion PyFunceble/checker/availability/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


import PyFunceble.facility
import PyFunceble.factory
import PyFunceble.storage
Expand Down
3 changes: 1 addition & 2 deletions PyFunceble/checker/availability/extras/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


import functools
import socket
from typing import Callable, Dict, List, Optional, Union
Expand Down Expand Up @@ -423,7 +422,7 @@ def switch_to_down_if_status_code(
of the given one.
"""

if not isinstance(status_code, (list, tuple)):
if not isinstance(status_code, (list, tuple, set)):
status_code = [status_code]

if any(self.status.http_status_code == x for x in status_code):
Expand Down
2 changes: 1 addition & 1 deletion PyFunceble/checker/availability/extras/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ExtraRulesHandler(ExtraRuleHandlerBase):
def __init__(self, status: Optional[AvailabilityCheckerStatus] = None) -> None:
self.regex_active2inactive = {
r"\.000webhostapp\.com": [
(self.switch_to_down_if_status_code, 410),
(self.switch_to_down_if_status_code, {410, 424}),
],
r"\.24\.eu$": [(self.switch_to_down_if_status_code, 503)],
r"\.altervista\.org$": [(self.switch_to_down_if_status_code, 403)],
Expand Down
1 change: 0 additions & 1 deletion PyFunceble/checker/availability/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


import PyFunceble.facility
import PyFunceble.factory
import PyFunceble.storage
Expand Down
1 change: 0 additions & 1 deletion PyFunceble/checker/availability/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


import PyFunceble.facility
import PyFunceble.factory
import PyFunceble.storage
Expand Down
1 change: 0 additions & 1 deletion PyFunceble/checker/reputation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


from typing import List, Optional

from sqlalchemy.orm import Session
Expand Down
1 change: 0 additions & 1 deletion PyFunceble/checker/reputation/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


from typing import List, Optional

from PyFunceble.checker.reputation.base import ReputationCheckerBase
Expand Down
1 change: 0 additions & 1 deletion PyFunceble/checker/reputation/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


from typing import List, Optional

from PyFunceble.checker.reputation.base import ReputationCheckerBase
Expand Down
1 change: 0 additions & 1 deletion PyFunceble/checker/reputation/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


from typing import List, Optional

from PyFunceble.checker.reputation.base import ReputationCheckerBase
Expand Down
8 changes: 6 additions & 2 deletions PyFunceble/checker/syntax/second_lvl_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ class SecondLvlDomainSyntaxChecker(DomainSyntaxCheckerBase):
"""

# pylint: disable=line-too-long
REGEX_VALID_DOMAIN: str = r"^(?=.{0,253}$)(([a-z0-9][a-z0-9-]{0,61}[a-z0-9]|[a-z0-9])\.)+((?=.*[^0-9])([a-z0-9][a-z0-9-]{0,61}[a-z0-9](?:\.)?|[a-z0-9](?:\.)?))$"
REGEX_VALID_RELAXED_DOMAIN: str = r"^(?=.{0,253}$)(([a-z0-9][a-z0-9_-]{0,61}[a-z0-9_-]|[a-z0-9])\.)+((?=.*[^0-9])([a-z0-9][a-z0-9-]{0,61}[a-z0-9](?:\.)?|[a-z0-9](?:\.)?))$"
REGEX_VALID_DOMAIN: str = (
r"^(?=.{0,253}$)(([a-z0-9][a-z0-9-]{0,61}[a-z0-9]|[a-z0-9])\.)+((?=.*[^0-9])([a-z0-9][a-z0-9-]{0,61}[a-z0-9](?:\.)?|[a-z0-9](?:\.)?))$"
)
REGEX_VALID_RELAXED_DOMAIN: str = (
r"^(?=.{0,253}$)(([a-z0-9][a-z0-9_-]{0,61}[a-z0-9_-]|[a-z0-9])\.)+((?=.*[^0-9])([a-z0-9][a-z0-9-]{0,61}[a-z0-9](?:\.)?|[a-z0-9](?:\.)?))$"
)

last_point_index: Optional[int] = None
"""
Expand Down
1 change: 1 addition & 0 deletions PyFunceble/checker/syntax/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import dataclasses
from typing import Optional

Expand Down
4 changes: 3 additions & 1 deletion PyFunceble/checker/syntax/subdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class SubDomainSyntaxChecker(DomainSyntaxCheckerBase):
"""

# pylint: disable=line-too-long
REGEX_VALID_SUBDOMAIN: str = r"^(?=.{0,253}$)(([a-z0-9_][a-z0-9-_]{0,61}[a-z0-9_-]|[a-z0-9])\.)+((?=.*)([a-z0-9][a-z0-9-]{0,61}[a-z0-9](?:\.)?|[a-z0-9](?:\.)?))$"
REGEX_VALID_SUBDOMAIN: str = (
r"^(?=.{0,253}$)(([a-z0-9_][a-z0-9-_]{0,61}[a-z0-9_-]|[a-z0-9])\.)+((?=.*)([a-z0-9][a-z0-9-]{0,61}[a-z0-9](?:\.)?|[a-z0-9](?:\.)?))$"
)

@DomainSyntaxCheckerBase.ensure_subject_is_given
def is_valid(self) -> bool:
Expand Down
1 change: 0 additions & 1 deletion PyFunceble/checker/syntax/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


import urllib.parse
from typing import Optional

Expand Down
6 changes: 3 additions & 3 deletions PyFunceble/cli/credential_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ def start(self, *, ignore_cli: bool = True) -> "CredentialLoader":
# We directly share the credential object into the DBSession object.
# This will let us use the DBSession without having to think about
# any other headache.
self.credential = (
PyFunceble.cli.factory.DBSession.credential
) = self.DB_TYPE2OBJ[self.db_type]()
self.credential = PyFunceble.cli.factory.DBSession.credential = (
self.DB_TYPE2OBJ[self.db_type]()
)

env_var_helper = EnvironmentVariableHelper(
env_file_path=self.credential.get_dot_env_file()
Expand Down
6 changes: 3 additions & 3 deletions PyFunceble/cli/file_preloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ def start(self, print_dots: bool = False) -> "FilePreloader":
raise exception

if not broken:
self.__description[self.__matching_index][
"previous_hash"
] = self.__description[self.__matching_index]["hash"]
self.__description[self.__matching_index]["previous_hash"] = (
self.__description[self.__matching_index]["hash"]
)

self.__save_description()

Expand Down
1 change: 0 additions & 1 deletion PyFunceble/cli/migrators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


from typing import Optional

from sqlalchemy.orm import Session
Expand Down
6 changes: 3 additions & 3 deletions PyFunceble/cli/processes/workers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def __init__(
self.input_queue = self._params["input_queue"] = input_queue
self.output_queue = self._params["output_queue"] = output_queue

self.continuous_integration = self._params[
"continuous_integration"
] = continuous_integration
self.continuous_integration = self._params["continuous_integration"] = (
continuous_integration
)

self.global_exit_event = self._params["global_exit_event"] = global_exit_event
self.exit_it = multiprocessing.Event()
Expand Down
7 changes: 3 additions & 4 deletions PyFunceble/cli/scripts/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
limitations under the License.
"""


import copy
import functools
import os
Expand Down Expand Up @@ -516,9 +515,9 @@ def update_version_file(self) -> "ProductionPrep":
if to_append not in self.version_file_content["deprecated"]:
self.version_file_content["deprecated"].append(to_append)

self.version_file_content[
"current_version"
] = PyFunceble.storage.PROJECT_VERSION
self.version_file_content["current_version"] = (
PyFunceble.storage.PROJECT_VERSION
)

self.dict_helper.set_subject(self.version_file_content).to_yaml_file(
self.VERSION_FILE_PATH
Expand Down
8 changes: 5 additions & 3 deletions PyFunceble/cli/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,11 @@
}

OUTPUTS: Optional[Box] = Box(
Merge(UNIX_OUTPUTS).into(UNIVERSAL_OUTPUTS)
if PlatformUtility.is_unix()
else Merge(WIN_OUTPUTS).into(UNIVERSAL_OUTPUTS),
(
Merge(UNIX_OUTPUTS).into(UNIVERSAL_OUTPUTS)
if PlatformUtility.is_unix()
else Merge(WIN_OUTPUTS).into(UNIVERSAL_OUTPUTS)
),
frozen_box=True,
)

Expand Down
4 changes: 1 addition & 3 deletions PyFunceble/cli/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ def get_subjects_from_line(
if cidr2subject is None:
cidr2subject = CIDR2Subject()

adblock_inputline2subject.aggressive = (
wildcard2subject.aggressive
) = (
adblock_inputline2subject.aggressive = wildcard2subject.aggressive = (
rpz_inputline2subject.aggressive
) = inputline2subject.aggressive = url2netloc.aggressive = bool(
PyFunceble.storage.CONFIGURATION.cli_decoding.aggressive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-08-21 11:42:07.044762
"""

from alembic import op
from sqlalchemy.exc import OperationalError

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-13 22:52:56.968513
"""

import sqlalchemy as sa
from alembic import op

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-13 19:45:41.893657
"""

import sqlalchemy as sa
from alembic import op

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-07 12:36:04.818466
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-07 12:37:52.018637
"""

import sqlalchemy as sa
from alembic import op

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-02-13 12:21:00.493002
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-08 17:34:59.349943
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-07 12:49:48.797794
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2021-12-04 23:52:11.861732
"""

import sqlalchemy as sa
from alembic import op

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-23 02:26:21.647125
"""

import sqlalchemy as sa
from alembic import op

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-08-15 20:12:26.768419
"""

import sqlalchemy as sa
from alembic import op

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-16 19:09:41.212679
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-08-22 17:27:52.087506
"""

from alembic import op
from sqlalchemy.dialects import mysql

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2020-12-07 12:33:43.650514
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-12-28 07:20:50.310072
"""

import sqlalchemy as sa
from alembic import op

Expand Down
Loading

0 comments on commit 3e5494e

Please sign in to comment.