PyFunceble-dev 4.3.0a21__py3-none-any.whl → 4.3.0a24__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyFunceble/checker/availability/base.py +7 -6
- PyFunceble/checker/availability/domain.py +18 -0
- PyFunceble/checker/availability/extras/base.py +4 -4
- PyFunceble/checker/availability/extras/dns.py +1 -1
- PyFunceble/checker/availability/extras/etoxic.py +3 -3
- PyFunceble/checker/availability/extras/parked.py +22 -20
- PyFunceble/checker/availability/extras/rules.py +5 -13
- PyFunceble/checker/availability/extras/subject_switch.py +4 -5
- PyFunceble/checker/availability/ip.py +18 -0
- PyFunceble/checker/availability/params.py +1 -1
- PyFunceble/checker/availability/status.py +9 -4
- PyFunceble/checker/availability/url.py +6 -0
- PyFunceble/checker/base.py +4 -0
- PyFunceble/checker/reputation/base.py +5 -2
- PyFunceble/checker/reputation/domain.py +11 -0
- PyFunceble/checker/reputation/ip.py +11 -0
- PyFunceble/checker/reputation/status.py +1 -1
- PyFunceble/checker/reputation/url.py +12 -1
- PyFunceble/checker/syntax/base.py +4 -1
- PyFunceble/checker/syntax/domain.py +4 -0
- PyFunceble/checker/syntax/ip.py +4 -0
- PyFunceble/checker/syntax/ipv4.py +10 -13
- PyFunceble/checker/syntax/ipv6.py +9 -11
- PyFunceble/checker/syntax/params.py +1 -1
- PyFunceble/checker/syntax/second_lvl_domain.py +3 -4
- PyFunceble/checker/syntax/subdomain.py +3 -4
- PyFunceble/checker/syntax/url.py +9 -6
- PyFunceble/checker/utils/whois.py +7 -11
- PyFunceble/cli/continuous_integration/base.py +14 -14
- PyFunceble/cli/credential_loader.py +4 -6
- PyFunceble/cli/entry_points/clean.py +0 -1
- PyFunceble/cli/entry_points/production.py +1 -1
- PyFunceble/cli/entry_points/pyfunceble/cli.py +11 -2
- PyFunceble/cli/execution_time.py +2 -2
- PyFunceble/cli/filesystem/cleanup.py +1 -3
- PyFunceble/cli/filesystem/dir_base.py +5 -1
- PyFunceble/cli/filesystem/dir_structure/backup.py +1 -2
- PyFunceble/cli/filesystem/dir_structure/base.py +0 -1
- PyFunceble/cli/filesystem/dir_structure/restore.py +5 -7
- PyFunceble/cli/filesystem/status_file.py +2 -3
- PyFunceble/cli/migrators/alembic.py +2 -4
- PyFunceble/cli/migrators/csv_file/inactive_source_delete.py +0 -1
- PyFunceble/cli/migrators/csv_file/whois_registrar_add.py +0 -1
- PyFunceble/cli/migrators/db_base.py +2 -2
- PyFunceble/cli/migrators/file_cleanup/base.py +3 -3
- PyFunceble/cli/migrators/file_cleanup/hashes_file.py +2 -3
- PyFunceble/cli/migrators/file_cleanup/mining_file.py +2 -3
- PyFunceble/cli/migrators/file_cleanup/production_config_file.py +2 -3
- PyFunceble/cli/migrators/mariadb/base.py +2 -4
- PyFunceble/cli/migrators/mariadb/file_and_status.py +1 -1
- PyFunceble/cli/migrators/mariadb/whois_record_idna_subject.py +0 -2
- PyFunceble/cli/processes/migrator.py +0 -1
- PyFunceble/cli/processes/workers/base.py +0 -1
- PyFunceble/cli/processes/workers/chancy_producer.py +1 -2
- PyFunceble/cli/processes/workers/dir_files_sorter.py +6 -14
- PyFunceble/cli/processes/workers/file_sorter.py +2 -9
- PyFunceble/cli/processes/workers/migrator.py +0 -1
- PyFunceble/cli/processes/workers/producer.py +2 -4
- PyFunceble/cli/processes/workers/tester.py +2 -3
- PyFunceble/cli/scripts/iana.py +14 -10
- PyFunceble/cli/scripts/production.py +2 -2
- PyFunceble/cli/scripts/public_suffix.py +2 -2
- PyFunceble/cli/system/integrator.py +1 -1
- PyFunceble/cli/system/launcher.py +14 -11
- PyFunceble/cli/utils/stdout.py +1 -1
- PyFunceble/cli/utils/testing.py +6 -16
- PyFunceble/config/compare.py +10 -9
- PyFunceble/config/loader.py +7 -4
- PyFunceble/converter/input_line2subject.py +2 -2
- PyFunceble/converter/internal_url.py +1 -1
- PyFunceble/converter/rpz_input_line2subject.py +2 -4
- PyFunceble/converter/subject2complements.py +4 -1
- PyFunceble/converter/url2netloc.py +3 -3
- PyFunceble/converter/wildcard2subject.py +3 -3
- PyFunceble/helpers/command.py +1 -1
- PyFunceble/helpers/dict.py +4 -4
- PyFunceble/helpers/file.py +2 -2
- PyFunceble/helpers/list.py +10 -7
- PyFunceble/helpers/merge.py +2 -2
- PyFunceble/helpers/regex.py +9 -11
- PyFunceble/query/dns/nameserver.py +9 -19
- PyFunceble/query/dns/query_tool.py +64 -205
- PyFunceble/query/dns/resolver.py +64 -51
- PyFunceble/query/netinfo/address.py +4 -6
- PyFunceble/query/netinfo/base.py +1 -1
- PyFunceble/query/netinfo/hostbyaddr.py +5 -8
- PyFunceble/query/requests/adapter/base.py +3 -3
- PyFunceble/query/requests/adapter/http.py +0 -1
- PyFunceble/query/requests/requester.py +6 -6
- PyFunceble/query/whois/converter/expiration_date.py +19 -8
- PyFunceble/query/whois/converter/month2unified.py +4 -6
- PyFunceble/query/whois/converter/registrar.py +18 -5
- PyFunceble/query/whois/query_tool.py +15 -18
- PyFunceble/storage.py +1 -1
- {pyfunceble_dev-4.3.0a21.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/METADATA +109 -108
- {pyfunceble_dev-4.3.0a21.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/RECORD +100 -100
- {pyfunceble_dev-4.3.0a21.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/WHEEL +1 -1
- {pyfunceble_dev-4.3.0a21.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/entry_points.txt +0 -0
- {pyfunceble_dev-4.3.0a21.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/licenses/LICENSE +0 -0
- {pyfunceble_dev-4.3.0a21.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/top_level.txt +0 -0
@@ -59,5 +59,5 @@ from PyFunceble.checker.params_base import CheckerParamsBase
|
|
59
59
|
@dataclasses.dataclass
|
60
60
|
class SyntaxCheckerParams(CheckerParamsBase):
|
61
61
|
"""
|
62
|
-
Provides the description of a syntax checker
|
62
|
+
Provides the description of a syntax checker parameters.
|
63
63
|
"""
|
@@ -53,7 +53,6 @@ License:
|
|
53
53
|
from typing import Optional
|
54
54
|
|
55
55
|
from PyFunceble.checker.syntax.domain_base import DomainSyntaxCheckerBase
|
56
|
-
from PyFunceble.helpers.regex import RegexHelper
|
57
56
|
|
58
57
|
|
59
58
|
class SecondLvlDomainSyntaxChecker(DomainSyntaxCheckerBase):
|
@@ -108,15 +107,15 @@ class SecondLvlDomainSyntaxChecker(DomainSyntaxCheckerBase):
|
|
108
107
|
if "." in subject_without_suffix:
|
109
108
|
return False
|
110
109
|
|
111
|
-
return
|
110
|
+
return self.regex_helper.set_regex(self.REGEX_VALID_DOMAIN).match(
|
112
111
|
self.idna_subject, return_match=False
|
113
|
-
) or
|
112
|
+
) or self.regex_helper.set_regex(self.REGEX_VALID_RELAXED_DOMAIN).match(
|
114
113
|
self.idna_subject, return_match=False
|
115
114
|
)
|
116
115
|
|
117
116
|
if "." in subject_without_extension:
|
118
117
|
return False
|
119
118
|
|
120
|
-
return
|
119
|
+
return self.regex_helper.set_regex(self.REGEX_VALID_DOMAIN).match(
|
121
120
|
self.idna_subject, return_match=False
|
122
121
|
)
|
@@ -51,7 +51,6 @@ License:
|
|
51
51
|
"""
|
52
52
|
|
53
53
|
from PyFunceble.checker.syntax.domain_base import DomainSyntaxCheckerBase
|
54
|
-
from PyFunceble.helpers.regex import RegexHelper
|
55
54
|
|
56
55
|
|
57
56
|
class SubDomainSyntaxChecker(DomainSyntaxCheckerBase):
|
@@ -89,19 +88,19 @@ class SubDomainSyntaxChecker(DomainSyntaxCheckerBase):
|
|
89
88
|
|
90
89
|
if subject_without_suffix:
|
91
90
|
if suffix.count(".") >= 2:
|
92
|
-
return
|
91
|
+
return self.regex_helper.set_regex(self.REGEX_VALID_SUBDOMAIN).match(
|
93
92
|
subject_without_extension, return_match=False
|
94
93
|
)
|
95
94
|
|
96
95
|
if "." in subject_without_suffix:
|
97
|
-
return
|
96
|
+
return self.regex_helper.set_regex(self.REGEX_VALID_SUBDOMAIN).match(
|
98
97
|
self.idna_subject, return_match=False
|
99
98
|
)
|
100
99
|
|
101
100
|
return False
|
102
101
|
|
103
102
|
if "." in subject_without_extension:
|
104
|
-
return
|
103
|
+
return self.regex_helper.set_regex(self.REGEX_VALID_SUBDOMAIN).match(
|
105
104
|
subject_without_extension, return_match=False
|
106
105
|
)
|
107
106
|
|
PyFunceble/checker/syntax/url.py
CHANGED
@@ -57,6 +57,8 @@ from PyFunceble.checker.base import CheckerBase
|
|
57
57
|
from PyFunceble.checker.syntax.base import SyntaxCheckerBase
|
58
58
|
from PyFunceble.checker.syntax.domain import DomainSyntaxChecker
|
59
59
|
from PyFunceble.checker.syntax.ip import IPSyntaxChecker
|
60
|
+
from PyFunceble.checker.syntax.params import SyntaxCheckerParams
|
61
|
+
from PyFunceble.checker.syntax.status import SyntaxCheckerStatus
|
60
62
|
|
61
63
|
|
62
64
|
class URLSyntaxChecker(SyntaxCheckerBase):
|
@@ -67,7 +69,11 @@ class URLSyntaxChecker(SyntaxCheckerBase):
|
|
67
69
|
Optional, The subject to work with.
|
68
70
|
"""
|
69
71
|
|
70
|
-
def subject_propagator(self) ->
|
72
|
+
def subject_propagator(self) -> "URLSyntaxChecker":
|
73
|
+
self.status = SyntaxCheckerStatus()
|
74
|
+
self.params = SyntaxCheckerParams()
|
75
|
+
self.status.params = self.params
|
76
|
+
|
71
77
|
self.status.subject_kind = "url"
|
72
78
|
|
73
79
|
return super().subject_propagator()
|
@@ -112,10 +118,7 @@ class URLSyntaxChecker(SyntaxCheckerBase):
|
|
112
118
|
if not hostname:
|
113
119
|
return False
|
114
120
|
|
115
|
-
|
121
|
+
return (
|
116
122
|
DomainSyntaxChecker(hostname).is_valid()
|
117
123
|
or IPSyntaxChecker(hostname).is_valid()
|
118
|
-
)
|
119
|
-
return True
|
120
|
-
|
121
|
-
return False
|
124
|
+
)
|
@@ -73,30 +73,26 @@ def get_whois_dataset_object(
|
|
73
73
|
A database session to use.
|
74
74
|
|
75
75
|
:raise ValueError:
|
76
|
-
When the given database type is
|
76
|
+
When the given database type is unknown.
|
77
77
|
:raise RuntimeError:
|
78
78
|
When the configuration was not loaded yet.
|
79
79
|
"""
|
80
80
|
|
81
81
|
if PyFunceble.facility.ConfigLoader.is_already_loaded():
|
82
|
-
result = None
|
83
|
-
|
84
82
|
if PyFunceble.storage.CONFIGURATION.cli_testing.db_type == "csv":
|
85
|
-
|
86
|
-
|
83
|
+
return CSVWhoisDataset().set_authorized(
|
84
|
+
bool(PyFunceble.storage.CONFIGURATION.cli_testing.whois_db)
|
85
|
+
)
|
86
|
+
|
87
|
+
if PyFunceble.storage.CONFIGURATION.cli_testing.db_type in (
|
87
88
|
"mariadb",
|
88
89
|
"mysql",
|
89
90
|
"postgresql",
|
90
91
|
):
|
91
|
-
|
92
|
-
|
93
|
-
if result:
|
94
|
-
result.set_authorized(
|
92
|
+
return SQLDBWhoisDataset(db_session=db_session).set_authorized(
|
95
93
|
bool(PyFunceble.storage.CONFIGURATION.cli_testing.whois_db)
|
96
94
|
)
|
97
95
|
|
98
|
-
return result
|
99
|
-
|
100
96
|
raise ValueError(
|
101
97
|
"<config.db_type> "
|
102
98
|
f"({PyFunceble.storage.CONFIGURATION.cli_testing.db_type}) is unknown."
|
@@ -72,19 +72,19 @@ class ContinuousIntegrationBase:
|
|
72
72
|
:param authorized:
|
73
73
|
The authorization to run.
|
74
74
|
:param git_email:
|
75
|
-
The email to apply while
|
75
|
+
The email to apply while initializing the git repository for push.
|
76
76
|
:param git_name:
|
77
|
-
The name to apply while
|
77
|
+
The name to apply while initializing the git repository for push.
|
78
78
|
:param git_branch:
|
79
79
|
The branch to use while testing.
|
80
80
|
:param git_distribution_branch:
|
81
81
|
The branch to push the results into.
|
82
82
|
:param token:
|
83
|
-
The token to apply while
|
83
|
+
The token to apply while initializing the git repository for push.
|
84
84
|
:param command:
|
85
85
|
The command to execute before each push (except the latest one).
|
86
86
|
:param end_command:
|
87
|
-
The
|
87
|
+
The command to execute at the very end.
|
88
88
|
:param commit_message:
|
89
89
|
The commit message to apply before each push (except the latest one).
|
90
90
|
:param end_commit_message:
|
@@ -202,7 +202,7 @@ class ContinuousIntegrationBase:
|
|
202
202
|
Otherwise, apply the given :code:`default`.
|
203
203
|
"""
|
204
204
|
|
205
|
-
def
|
205
|
+
def inner_method(func):
|
206
206
|
@functools.wraps(func)
|
207
207
|
def wrapper(self, *args, **kwargs):
|
208
208
|
if self.authorized:
|
@@ -211,7 +211,7 @@ class ContinuousIntegrationBase:
|
|
211
211
|
|
212
212
|
return wrapper
|
213
213
|
|
214
|
-
return
|
214
|
+
return inner_method
|
215
215
|
|
216
216
|
def ensure_git_email_is_given(func): # pylint: disable=no-self-argument
|
217
217
|
"""
|
@@ -609,7 +609,7 @@ class ContinuousIntegrationBase:
|
|
609
609
|
raise TypeError(f"<value> should be {str}, {type(value)} given.")
|
610
610
|
|
611
611
|
if not value:
|
612
|
-
raise ValueError("<value> should not be
|
612
|
+
raise ValueError("<value> should not be empty.")
|
613
613
|
|
614
614
|
self._command = value
|
615
615
|
|
@@ -651,7 +651,7 @@ class ContinuousIntegrationBase:
|
|
651
651
|
raise TypeError(f"<value> should be {str}, {type(value)} given.")
|
652
652
|
|
653
653
|
if not value:
|
654
|
-
raise ValueError("<value> should not be
|
654
|
+
raise ValueError("<value> should not be empty.")
|
655
655
|
|
656
656
|
self._end_command = value
|
657
657
|
|
@@ -693,7 +693,7 @@ class ContinuousIntegrationBase:
|
|
693
693
|
raise TypeError(f"<value> should be {str}, {type(value)} given.")
|
694
694
|
|
695
695
|
if not value:
|
696
|
-
raise ValueError("<value> should not be
|
696
|
+
raise ValueError("<value> should not be empty.")
|
697
697
|
|
698
698
|
self._commit_message = value
|
699
699
|
|
@@ -735,7 +735,7 @@ class ContinuousIntegrationBase:
|
|
735
735
|
raise TypeError(f"<value> should be {str}, {type(value)} given.")
|
736
736
|
|
737
737
|
if not value:
|
738
|
-
raise ValueError("<value> should not be
|
738
|
+
raise ValueError("<value> should not be empty.")
|
739
739
|
|
740
740
|
self._end_commit_message = value
|
741
741
|
|
@@ -835,7 +835,7 @@ class ContinuousIntegrationBase:
|
|
835
835
|
@staticmethod
|
836
836
|
def exec_command(command: str, allow_stdout: bool) -> None:
|
837
837
|
"""
|
838
|
-
|
838
|
+
Executes the given command.
|
839
839
|
|
840
840
|
:param command:
|
841
841
|
The command to execute.
|
@@ -1293,17 +1293,17 @@ class ContinuousIntegrationBase:
|
|
1293
1293
|
The purpose of this method is to be able to have some custom init based
|
1294
1294
|
on the CI we are currently on.
|
1295
1295
|
|
1296
|
-
The init method should be manually started before
|
1296
|
+
The init method should be manually started before running any further
|
1297
1297
|
action.
|
1298
1298
|
|
1299
1299
|
.. warning::
|
1300
1300
|
We assume that we are aware that you should run this method first.
|
1301
1301
|
"""
|
1302
1302
|
|
1303
|
-
PyFunceble.facility.Logger.info("Started
|
1303
|
+
PyFunceble.facility.Logger.info("Started initialization of workflow.")
|
1304
1304
|
|
1305
1305
|
self.init_git()
|
1306
1306
|
|
1307
|
-
PyFunceble.facility.Logger.info("Finished
|
1307
|
+
PyFunceble.facility.Logger.info("Finished initialization of workflow.")
|
1308
1308
|
|
1309
1309
|
return self
|
@@ -66,7 +66,7 @@ from PyFunceble.helpers.environment_variable import EnvironmentVariableHelper
|
|
66
66
|
|
67
67
|
class CredentialLoader:
|
68
68
|
"""
|
69
|
-
Provides our
|
69
|
+
Provides our credentials loader.
|
70
70
|
|
71
71
|
The idea is to have an interface which provides the credential to use
|
72
72
|
but at the same time load and initiate the credential interface after
|
@@ -123,7 +123,7 @@ class CredentialLoader:
|
|
123
123
|
Otherwise, apply the given :code:`default`.
|
124
124
|
"""
|
125
125
|
|
126
|
-
def
|
126
|
+
def inner_method(func):
|
127
127
|
@functools.wraps(func)
|
128
128
|
def wrapper(self, *args, **kwargs):
|
129
129
|
if self.authorized:
|
@@ -132,7 +132,7 @@ class CredentialLoader:
|
|
132
132
|
|
133
133
|
return wrapper
|
134
134
|
|
135
|
-
return
|
135
|
+
return inner_method
|
136
136
|
|
137
137
|
def start_if_not_started(func): # pylint: disable=no-self-argument
|
138
138
|
"""
|
@@ -248,9 +248,7 @@ class CredentialLoader:
|
|
248
248
|
else:
|
249
249
|
user_input = input(message)
|
250
250
|
|
251
|
-
|
252
|
-
return user_input
|
253
|
-
return default
|
251
|
+
return user_input or default
|
254
252
|
|
255
253
|
@execute_if_authorized(None)
|
256
254
|
@ensure_db_type_is_given
|
@@ -71,7 +71,7 @@ def producer() -> None: # pylint: disable=too-many-statements
|
|
71
71
|
description = (
|
72
72
|
f"{colorama.Style.BRIGHT}{colorama.Fore.GREEN}PyFunceble Production Preparator"
|
73
73
|
f"{colorama.Style.RESET_ALL} - "
|
74
|
-
"The Production
|
74
|
+
"The Production preparator for PyFunceble."
|
75
75
|
)
|
76
76
|
|
77
77
|
parser = argparse.ArgumentParser(
|
@@ -134,13 +134,18 @@ def add_arguments_to_parser(
|
|
134
134
|
if "dest" in opt_args:
|
135
135
|
opt_args["dest"] = opt_args["dest"].replace(".", "__")
|
136
136
|
|
137
|
+
complete_value = opt_args.pop("complete", None)
|
138
|
+
|
137
139
|
for index, value in enumerate(pos_args):
|
138
140
|
if value.startswith("-") and "." not in value:
|
139
141
|
continue
|
140
142
|
|
141
143
|
pos_args[index] = value.replace(".", "__")
|
142
144
|
|
143
|
-
|
145
|
+
if not complete_value:
|
146
|
+
parser.add_argument(*pos_args, **opt_args)
|
147
|
+
else:
|
148
|
+
parser.add_argument(*pos_args, **opt_args).complete = complete_value
|
144
149
|
|
145
150
|
|
146
151
|
def get_source_group_data() -> List[Tuple[List[str], dict]]:
|
@@ -188,6 +193,7 @@ def get_source_group_data() -> List[Tuple[List[str], dict]]:
|
|
188
193
|
"\nIf remote (RAW link) file is given, PyFunceble will download "
|
189
194
|
"it,\n and test the content of the given RAW link as if it was a"
|
190
195
|
" locally stored file.",
|
196
|
+
"complete": shtab.FILE,
|
191
197
|
},
|
192
198
|
),
|
193
199
|
(
|
@@ -206,6 +212,7 @@ def get_source_group_data() -> List[Tuple[List[str], dict]]:
|
|
206
212
|
" locally stored file. "
|
207
213
|
"\n\nThis argument test if an URL is available. It ONLY test "
|
208
214
|
"full URLs.",
|
215
|
+
"complete": shtab.FILE,
|
209
216
|
},
|
210
217
|
),
|
211
218
|
]
|
@@ -466,7 +473,7 @@ def get_test_control_group_data() -> List[Tuple[List[str], dict]]:
|
|
466
473
|
{
|
467
474
|
"dest": "self_contained.lookup.netinfo",
|
468
475
|
"action": "store_true",
|
469
|
-
"help": "Only perform a network information (or
|
476
|
+
"help": "Only perform a network information (or network "
|
470
477
|
"socket) lookup.",
|
471
478
|
},
|
472
479
|
),
|
@@ -1242,6 +1249,7 @@ def get_default_group_data() -> List[Tuple[List[str], dict]]:
|
|
1242
1249
|
"help": "Sets the configuration file to use. It can be a\n"
|
1243
1250
|
"local or remote file. Please note that this configuration can be\n"
|
1244
1251
|
"overwritten by your overwrite configuration file.",
|
1252
|
+
"complete": shtab.FILE,
|
1245
1253
|
},
|
1246
1254
|
),
|
1247
1255
|
(
|
@@ -1252,6 +1260,7 @@ def get_default_group_data() -> List[Tuple[List[str], dict]]:
|
|
1252
1260
|
"dest": "config_dir",
|
1253
1261
|
"type": os.path.realpath,
|
1254
1262
|
"help": "Sets the configuration directory to use.",
|
1263
|
+
"complete": shtab.DIRECTORY,
|
1255
1264
|
},
|
1256
1265
|
),
|
1257
1266
|
]
|
PyFunceble/cli/execution_time.py
CHANGED
@@ -90,7 +90,7 @@ class ExecutionTime:
|
|
90
90
|
Otherwise, apply the given :code:`default`.
|
91
91
|
"""
|
92
92
|
|
93
|
-
def
|
93
|
+
def inner_method(func):
|
94
94
|
@functools.wraps(func)
|
95
95
|
def wrapper(self, *args, **kwargs):
|
96
96
|
if self.authorized:
|
@@ -99,7 +99,7 @@ class ExecutionTime:
|
|
99
99
|
|
100
100
|
return wrapper
|
101
101
|
|
102
|
-
return
|
102
|
+
return inner_method
|
103
103
|
|
104
104
|
@staticmethod
|
105
105
|
def split_difference(start: datetime.datetime, end: datetime.datetime) -> dict:
|
@@ -55,8 +55,6 @@ from typing import List
|
|
55
55
|
|
56
56
|
import PyFunceble.cli.facility
|
57
57
|
import PyFunceble.cli.factory
|
58
|
-
import PyFunceble.cli.utils.testing
|
59
|
-
import PyFunceble.sessions
|
60
58
|
from PyFunceble.cli.filesystem.dir_base import FilesystemDirBase
|
61
59
|
from PyFunceble.database.sqlalchemy.all_schemas import Continue, Inactive
|
62
60
|
from PyFunceble.helpers.file import FileHelper
|
@@ -71,7 +69,7 @@ class FilesystemCleanup(FilesystemDirBase):
|
|
71
69
|
|
72
70
|
def clean_database(self) -> "FilesystemCleanup":
|
73
71
|
"""
|
74
|
-
Cleanups the
|
72
|
+
Cleanups the unneeded data that were stored in the database.
|
75
73
|
|
76
74
|
.. warning::
|
77
75
|
This method cleans everything except the WHOIS records.
|
@@ -70,6 +70,8 @@ class FilesystemDirBase:
|
|
70
70
|
|
71
71
|
INLINE_DEST: str = "_inline_"
|
72
72
|
|
73
|
+
directory_helper: Optional[DirectoryHelper] = None
|
74
|
+
|
73
75
|
def __init__(
|
74
76
|
self,
|
75
77
|
parent_dirname: Optional[str] = None,
|
@@ -83,6 +85,8 @@ class FilesystemDirBase:
|
|
83
85
|
|
84
86
|
self.db_session = db_session
|
85
87
|
|
88
|
+
self.directory_helper = DirectoryHelper()
|
89
|
+
|
86
90
|
@property
|
87
91
|
def parent_dirname(self) -> Optional[str]:
|
88
92
|
"""
|
@@ -187,5 +191,5 @@ class FilesystemDirBase:
|
|
187
191
|
else:
|
188
192
|
result = PyFunceble.cli.storage.OUTPUT_DIRECTORY
|
189
193
|
|
190
|
-
|
194
|
+
self.directory_helper.set_path(result).create()
|
191
195
|
return result
|
@@ -55,7 +55,6 @@ import os
|
|
55
55
|
import PyFunceble.facility
|
56
56
|
from PyFunceble.cli.filesystem.dir_structure.base import DirectoryStructureBase
|
57
57
|
from PyFunceble.helpers.dict import DictHelper
|
58
|
-
from PyFunceble.helpers.directory import DirectoryHelper
|
59
58
|
from PyFunceble.helpers.file import FileHelper
|
60
59
|
from PyFunceble.helpers.hash import HashHelper
|
61
60
|
|
@@ -75,7 +74,7 @@ class DirectoryStructureBackup(DirectoryStructureBase):
|
|
75
74
|
file_helper = FileHelper()
|
76
75
|
hash_helper = HashHelper()
|
77
76
|
|
78
|
-
for file in
|
77
|
+
for file in self.directory_helper.set_path(base_dir).list_all_files():
|
79
78
|
file_helper.set_path(file)
|
80
79
|
reduced_path = self.get_path_without_base_dir(file)
|
81
80
|
|
@@ -58,7 +58,6 @@ try:
|
|
58
58
|
except ImportError: # pragma: no cover ## Retro compatibility
|
59
59
|
import importlib_resources as package_resources
|
60
60
|
|
61
|
-
|
62
61
|
from PyFunceble.cli.filesystem.cleanup import FilesystemCleanup
|
63
62
|
from PyFunceble.cli.filesystem.dir_base import FilesystemDirBase
|
64
63
|
|
@@ -55,7 +55,6 @@ import os
|
|
55
55
|
import PyFunceble.cli.storage
|
56
56
|
from PyFunceble.cli.filesystem.dir_structure.base import DirectoryStructureBase
|
57
57
|
from PyFunceble.helpers.dict import DictHelper
|
58
|
-
from PyFunceble.helpers.directory import DirectoryHelper
|
59
58
|
from PyFunceble.helpers.file import FileHelper
|
60
59
|
from PyFunceble.utils.platform import PlatformUtility
|
61
60
|
|
@@ -99,15 +98,14 @@ class DirectoryStructureRestoration(DirectoryStructureBase):
|
|
99
98
|
backup = self.get_backup_data()
|
100
99
|
|
101
100
|
base_dir = self.get_output_basedir()
|
102
|
-
dir_helper = DirectoryHelper()
|
103
101
|
file_helper = FileHelper()
|
104
102
|
|
105
|
-
if
|
106
|
-
for root, _, files in os.walk(
|
103
|
+
if self.directory_helper.set_path(base_dir).exists():
|
104
|
+
for root, _, files in os.walk(self.directory_helper.path):
|
107
105
|
reduced_path = self.get_path_without_base_dir(root)
|
108
106
|
|
109
107
|
if reduced_path not in backup and root != reduced_path:
|
110
|
-
|
108
|
+
self.directory_helper.set_path(root).delete()
|
111
109
|
|
112
110
|
PyFunceble.facility.Logger.debug(
|
113
111
|
"Added %r into the list of directories to delete. "
|
@@ -117,10 +115,10 @@ class DirectoryStructureRestoration(DirectoryStructureBase):
|
|
117
115
|
continue
|
118
116
|
|
119
117
|
for directory, files in backup.items():
|
120
|
-
|
118
|
+
self.directory_helper.set_path(os.path.join(base_dir, directory)).create()
|
121
119
|
|
122
120
|
for file, dataset in files.items():
|
123
|
-
file_full_path = os.path.join(
|
121
|
+
file_full_path = os.path.join(self.directory_helper.path, file)
|
124
122
|
|
125
123
|
if (
|
126
124
|
file == ".gitignore"
|
@@ -66,7 +66,6 @@ from PyFunceble.cli.filesystem.dir_structure.restore import (
|
|
66
66
|
DirectoryStructureRestoration,
|
67
67
|
)
|
68
68
|
from PyFunceble.cli.filesystem.printer.file import FilePrinter
|
69
|
-
from PyFunceble.helpers.directory import DirectoryHelper
|
70
69
|
from PyFunceble.utils.platform import PlatformUtility
|
71
70
|
|
72
71
|
|
@@ -535,7 +534,7 @@ class StatusFileGenerator(FilesystemDirBase):
|
|
535
534
|
|
536
535
|
result = super().get_output_basedir()
|
537
536
|
|
538
|
-
if not
|
537
|
+
if not self.directory_helper.set_path(result).exists():
|
539
538
|
DirectoryStructureRestoration(self.parent_dirname).start()
|
540
539
|
return result
|
541
540
|
|
@@ -672,7 +671,7 @@ class StatusFileGenerator(FilesystemDirBase):
|
|
672
671
|
)
|
673
672
|
|
674
673
|
if self.test_dataset and "from_inactive" in self.test_dataset:
|
675
|
-
# Let's generate the
|
674
|
+
# Let's generate the suspicious file :-)
|
676
675
|
if self.status.status in [
|
677
676
|
PyFunceble.storage.STATUS.up,
|
678
677
|
PyFunceble.storage.STATUS.valid,
|
@@ -68,10 +68,8 @@ from alembic import command as alembic_command
|
|
68
68
|
from alembic.script.base import ScriptDirectory
|
69
69
|
|
70
70
|
import PyFunceble.cli.facility
|
71
|
-
import PyFunceble.cli.factory
|
72
71
|
import PyFunceble.cli.storage
|
73
72
|
import PyFunceble.facility
|
74
|
-
import PyFunceble.sessions
|
75
73
|
from PyFunceble.cli.migrators.db_base import DBMigratorBase
|
76
74
|
|
77
75
|
|
@@ -97,7 +95,7 @@ class Alembic:
|
|
97
95
|
Otherwise, apply the given :code:`default`.
|
98
96
|
"""
|
99
97
|
|
100
|
-
def
|
98
|
+
def inner_method(func):
|
101
99
|
@functools.wraps(func)
|
102
100
|
def wrapper(self, *args, **kwargs):
|
103
101
|
if self.authorized:
|
@@ -106,7 +104,7 @@ class Alembic:
|
|
106
104
|
|
107
105
|
return wrapper
|
108
106
|
|
109
|
-
return
|
107
|
+
return inner_method
|
110
108
|
|
111
109
|
@property
|
112
110
|
def authorized(self):
|
@@ -75,7 +75,7 @@ class DBMigratorBase(MigratorBase):
|
|
75
75
|
Otherwise, apply the given :code:`default`.
|
76
76
|
"""
|
77
77
|
|
78
|
-
def
|
78
|
+
def inner_method(func):
|
79
79
|
@functools.wraps(func)
|
80
80
|
def wrapper(self, *args, **kwargs):
|
81
81
|
if self.authorized:
|
@@ -84,7 +84,7 @@ class DBMigratorBase(MigratorBase):
|
|
84
84
|
|
85
85
|
return wrapper
|
86
86
|
|
87
|
-
return
|
87
|
+
return inner_method
|
88
88
|
|
89
89
|
@property
|
90
90
|
def authorized(self):
|
@@ -59,7 +59,7 @@ from PyFunceble.cli.utils.stdout import print_single_line
|
|
59
59
|
from PyFunceble.helpers.file import FileHelper
|
60
60
|
|
61
61
|
|
62
|
-
class
|
62
|
+
class FileCleanupMigratorBase(MigratorBase):
|
63
63
|
"""
|
64
64
|
Provides the base of all file cleanup related migration classes.
|
65
65
|
"""
|
@@ -85,7 +85,7 @@ class FileClenupMigratorBase(MigratorBase):
|
|
85
85
|
return wrapper
|
86
86
|
|
87
87
|
@ensure_source_file_is_given
|
88
|
-
def migrate(self) -> "
|
88
|
+
def migrate(self) -> "FileCleanupMigratorBase":
|
89
89
|
"""
|
90
90
|
Provides the migrator (itself)
|
91
91
|
"""
|
@@ -98,7 +98,7 @@ class FileClenupMigratorBase(MigratorBase):
|
|
98
98
|
if self.print_action_to_stdout:
|
99
99
|
print_single_line()
|
100
100
|
|
101
|
-
def start(self) -> "
|
101
|
+
def start(self) -> "FileCleanupMigratorBase":
|
102
102
|
"""
|
103
103
|
Starts the migration and everything related to it.
|
104
104
|
"""
|
@@ -53,11 +53,10 @@ License:
|
|
53
53
|
import os
|
54
54
|
|
55
55
|
import PyFunceble.cli.storage
|
56
|
-
|
57
|
-
from PyFunceble.cli.migrators.file_cleanup.base import FileClenupMigratorBase
|
56
|
+
from PyFunceble.cli.migrators.file_cleanup.base import FileCleanupMigratorBase
|
58
57
|
|
59
58
|
|
60
|
-
class HashesFileCleanupMigrator(
|
59
|
+
class HashesFileCleanupMigrator(FileCleanupMigratorBase):
|
61
60
|
"""
|
62
61
|
Provides the interface for the cleanup of the hashes file.
|
63
62
|
"""
|
@@ -53,11 +53,10 @@ License:
|
|
53
53
|
import os
|
54
54
|
|
55
55
|
import PyFunceble.cli.storage
|
56
|
-
|
57
|
-
from PyFunceble.cli.migrators.file_cleanup.base import FileClenupMigratorBase
|
56
|
+
from PyFunceble.cli.migrators.file_cleanup.base import FileCleanupMigratorBase
|
58
57
|
|
59
58
|
|
60
|
-
class MiningFileCleanupMigrator(
|
59
|
+
class MiningFileCleanupMigrator(FileCleanupMigratorBase):
|
61
60
|
"""
|
62
61
|
Provides the interface for the cleanup of the mining file.
|
63
62
|
"""
|
@@ -52,12 +52,11 @@ License:
|
|
52
52
|
|
53
53
|
import os
|
54
54
|
|
55
|
-
import PyFunceble.cli.storage
|
56
55
|
import PyFunceble.storage
|
57
|
-
from PyFunceble.cli.migrators.file_cleanup.base import
|
56
|
+
from PyFunceble.cli.migrators.file_cleanup.base import FileCleanupMigratorBase
|
58
57
|
|
59
58
|
|
60
|
-
class ProductionConfigFileCleanupMigrator(
|
59
|
+
class ProductionConfigFileCleanupMigrator(FileCleanupMigratorBase):
|
61
60
|
"""
|
62
61
|
Provides the interface for the cleanup of the
|
63
62
|
:code:`.PyFunceble_production.yaml` file.
|