Skip to content

Commit 84f8e56

Browse files
committed
Improve handling around cli.
1 parent f34e048 commit 84f8e56

37 files changed

+100
-145
lines changed

PyFunceble/cli/continuous_integration/base.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ class ContinuousIntegrationBase:
7272
:param authorized:
7373
The authorization to run.
7474
:param git_email:
75-
The email to apply while initilizing the git repository for push.
75+
The email to apply while initializing the git repository for push.
7676
:param git_name:
77-
The name to apply while initilizing the git repository for push.
77+
The name to apply while initializing the git repository for push.
7878
:param git_branch:
7979
The branch to use while testing.
8080
:param git_distribution_branch:
8181
The branch to push the results into.
8282
:param token:
83-
The token to apply while initilizing the git repository for push.
83+
The token to apply while initializing the git repository for push.
8484
:param command:
8585
The command to execute before each push (except the latest one).
8686
:param end_command:
87-
The commant to execute at the very end.
87+
The command to execute at the very end.
8888
:param commit_message:
8989
The commit message to apply before each push (except the latest one).
9090
:param end_commit_message:
@@ -202,7 +202,7 @@ def execute_if_authorized(default: Any = None): # pylint: disable=no-self-argum
202202
Otherwise, apply the given :code:`default`.
203203
"""
204204

205-
def inner_metdhod(func):
205+
def inner_method(func):
206206
@functools.wraps(func)
207207
def wrapper(self, *args, **kwargs):
208208
if self.authorized:
@@ -211,7 +211,7 @@ def wrapper(self, *args, **kwargs):
211211

212212
return wrapper
213213

214-
return inner_metdhod
214+
return inner_method
215215

216216
def ensure_git_email_is_given(func): # pylint: disable=no-self-argument
217217
"""
@@ -609,7 +609,7 @@ def command(self, value: str) -> None:
609609
raise TypeError(f"<value> should be {str}, {type(value)} given.")
610610

611611
if not value:
612-
raise ValueError("<value> should not be empy.")
612+
raise ValueError("<value> should not be empty.")
613613

614614
self._command = value
615615

@@ -651,7 +651,7 @@ def end_command(self, value: str) -> None:
651651
raise TypeError(f"<value> should be {str}, {type(value)} given.")
652652

653653
if not value:
654-
raise ValueError("<value> should not be empy.")
654+
raise ValueError("<value> should not be empty.")
655655

656656
self._end_command = value
657657

@@ -693,7 +693,7 @@ def commit_message(self, value: str) -> None:
693693
raise TypeError(f"<value> should be {str}, {type(value)} given.")
694694

695695
if not value:
696-
raise ValueError("<value> should not be empy.")
696+
raise ValueError("<value> should not be empty.")
697697

698698
self._commit_message = value
699699

@@ -735,7 +735,7 @@ def end_commit_message(self, value: str) -> None:
735735
raise TypeError(f"<value> should be {str}, {type(value)} given.")
736736

737737
if not value:
738-
raise ValueError("<value> should not be empy.")
738+
raise ValueError("<value> should not be empty.")
739739

740740
self._end_commit_message = value
741741

@@ -835,7 +835,7 @@ def get_remote_destination():
835835
@staticmethod
836836
def exec_command(command: str, allow_stdout: bool) -> None:
837837
"""
838-
Exceutes the given command.
838+
Executes the given command.
839839
840840
:param command:
841841
The command to execute.
@@ -1293,17 +1293,17 @@ def init(self) -> "ContinuousIntegrationBase":
12931293
The purpose of this method is to be able to have some custom init based
12941294
on the CI we are currently on.
12951295
1296-
The init method should be manually started before runing any further
1296+
The init method should be manually started before running any further
12971297
action.
12981298
12991299
.. warning::
13001300
We assume that we are aware that you should run this method first.
13011301
"""
13021302

1303-
PyFunceble.facility.Logger.info("Started initizalization of workflow.")
1303+
PyFunceble.facility.Logger.info("Started initialization of workflow.")
13041304

13051305
self.init_git()
13061306

1307-
PyFunceble.facility.Logger.info("Finished initizalization of workflow.")
1307+
PyFunceble.facility.Logger.info("Finished initialization of workflow.")
13081308

13091309
return self

PyFunceble/cli/credential_loader.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
class CredentialLoader:
6868
"""
69-
Provides our creadential loader.
69+
Provides our credentials loader.
7070
7171
The idea is to have an interface which provides the credential to use
7272
but at the same time load and initiate the credential interface after
@@ -123,7 +123,7 @@ def execute_if_authorized(default: Any = None): # pylint: disable=no-self-argum
123123
Otherwise, apply the given :code:`default`.
124124
"""
125125

126-
def inner_metdhod(func):
126+
def inner_method(func):
127127
@functools.wraps(func)
128128
def wrapper(self, *args, **kwargs):
129129
if self.authorized:
@@ -132,7 +132,7 @@ def wrapper(self, *args, **kwargs):
132132

133133
return wrapper
134134

135-
return inner_metdhod
135+
return inner_method
136136

137137
def start_if_not_started(func): # pylint: disable=no-self-argument
138138
"""
@@ -248,9 +248,7 @@ def ask_for_info(self, var_name: str, default: Any) -> str:
248248
else:
249249
user_input = input(message)
250250

251-
if user_input:
252-
return user_input
253-
return default
251+
return user_input or default
254252

255253
@execute_if_authorized(None)
256254
@ensure_db_type_is_given

PyFunceble/cli/entry_points/clean.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757

5858
import colorama
5959

60-
import PyFunceble.cli.facility
6160
import PyFunceble.cli.storage
6261
import PyFunceble.cli.utils.ascii_logo
6362
import PyFunceble.facility

PyFunceble/cli/entry_points/production.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def producer() -> None: # pylint: disable=too-many-statements
7171
description = (
7272
f"{colorama.Style.BRIGHT}{colorama.Fore.GREEN}PyFunceble Production Preparator"
7373
f"{colorama.Style.RESET_ALL} - "
74-
"The Production peparator for PyFunceble."
74+
"The Production preparator for PyFunceble."
7575
)
7676

7777
parser = argparse.ArgumentParser(

PyFunceble/cli/entry_points/pyfunceble/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def get_test_control_group_data() -> List[Tuple[List[str], dict]]:
473473
{
474474
"dest": "self_contained.lookup.netinfo",
475475
"action": "store_true",
476-
"help": "Only perform a network information (or networket "
476+
"help": "Only perform a network information (or network "
477477
"socket) lookup.",
478478
},
479479
),

PyFunceble/cli/execution_time.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def execute_if_authorized(default: Any = None): # pylint: disable=no-self-argum
9090
Otherwise, apply the given :code:`default`.
9191
"""
9292

93-
def inner_metdhod(func):
93+
def inner_method(func):
9494
@functools.wraps(func)
9595
def wrapper(self, *args, **kwargs):
9696
if self.authorized:
@@ -99,7 +99,7 @@ def wrapper(self, *args, **kwargs):
9999

100100
return wrapper
101101

102-
return inner_metdhod
102+
return inner_method
103103

104104
@staticmethod
105105
def split_difference(start: datetime.datetime, end: datetime.datetime) -> dict:

PyFunceble/cli/filesystem/cleanup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@
5555

5656
import PyFunceble.cli.facility
5757
import PyFunceble.cli.factory
58-
import PyFunceble.cli.utils.testing
59-
import PyFunceble.sessions
6058
from PyFunceble.cli.filesystem.dir_base import FilesystemDirBase
6159
from PyFunceble.database.sqlalchemy.all_schemas import Continue, Inactive
6260
from PyFunceble.helpers.file import FileHelper
@@ -71,7 +69,7 @@ class FilesystemCleanup(FilesystemDirBase):
7169

7270
def clean_database(self) -> "FilesystemCleanup":
7371
"""
74-
Cleanups the uneeded data that were stored in the database.
72+
Cleanups the unneeded data that were stored in the database.
7573
7674
.. warning::
7775
This method cleans everything except the WHOIS records.

PyFunceble/cli/filesystem/dir_base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class FilesystemDirBase:
7070

7171
INLINE_DEST: str = "_inline_"
7272

73+
directory_helper: Optional[DirectoryHelper] = None
74+
7375
def __init__(
7476
self,
7577
parent_dirname: Optional[str] = None,
@@ -83,6 +85,8 @@ def __init__(
8385

8486
self.db_session = db_session
8587

88+
self.directory_helper = DirectoryHelper()
89+
8690
@property
8791
def parent_dirname(self) -> Optional[str]:
8892
"""
@@ -187,5 +191,5 @@ def get_output_basedir(self) -> str:
187191
else:
188192
result = PyFunceble.cli.storage.OUTPUT_DIRECTORY
189193

190-
DirectoryHelper(result).create()
194+
self.directory_helper.set_path(result).create()
191195
return result

PyFunceble/cli/filesystem/dir_structure/backup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import PyFunceble.facility
5656
from PyFunceble.cli.filesystem.dir_structure.base import DirectoryStructureBase
5757
from PyFunceble.helpers.dict import DictHelper
58-
from PyFunceble.helpers.directory import DirectoryHelper
5958
from PyFunceble.helpers.file import FileHelper
6059
from PyFunceble.helpers.hash import HashHelper
6160

@@ -75,7 +74,7 @@ def get_backup_data(self) -> dict:
7574
file_helper = FileHelper()
7675
hash_helper = HashHelper()
7776

78-
for file in DirectoryHelper(base_dir).list_all_files():
77+
for file in self.directory_helper.set_path(base_dir).list_all_files():
7978
file_helper.set_path(file)
8079
reduced_path = self.get_path_without_base_dir(file)
8180

PyFunceble/cli/filesystem/dir_structure/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
except ImportError: # pragma: no cover ## Retro compatibility
5959
import importlib_resources as package_resources
6060

61-
6261
from PyFunceble.cli.filesystem.cleanup import FilesystemCleanup
6362
from PyFunceble.cli.filesystem.dir_base import FilesystemDirBase
6463

0 commit comments

Comments
 (0)