Fixed for split arguments

This commit is contained in:
Dimitris Zlatanidis 2024-04-10 12:18:40 +03:00
parent 7ec4e188d6
commit 5a9f072e61
5 changed files with 30 additions and 25 deletions

View file

@ -35,7 +35,7 @@ class CheckUpdates(Configs):
proxy_basic_auth=f'{self.proxy_username}:{self.proxy_password}')
self.option_for_repository: bool = self.utils.is_option(
('-o', '--repository='), flags)
('-o', '--repository'), flags)
self.option_for_check: bool = self.utils.is_option(
('-c', '--check'), flags)

View file

@ -43,7 +43,7 @@ class DownloadOnly(Configs):
}
self.option_for_directory: bool = self.utils.is_option(
('-z', '--directory='), flags)
('-z', '--directory'), flags)
def packages(self, packages: list) -> None:
packages: list = self.utils.apply_package_pattern(self.data, packages)

View file

@ -70,9 +70,9 @@ class Menu(Configs):
self.flag_short_parallel: str = '-P'
self.flag_no_case: str = '--no-case'
self.flag_short_no_case: str = '-m'
self.flag_repository: str = '--repository='
self.flag_repository: str = '--repository'
self.flag_short_repository: str = '-o'
self.flag_directory: str = '--directory='
self.flag_directory: str = '--directory'
self.flag_short_directory: str = '-z'
self.flag_searches: tuple = (
@ -363,36 +363,41 @@ class Menu(Configs):
Split the option ['--directory'] and ['/path/to/download/'].
"""
remove_args: list = []
for arg in self.args:
split_arg: list = arg.split('=')
if arg.startswith(self.flag_directory):
self.directory: str = arg.split('=')[1]
self.args.remove(arg)
self.args.append(self.flag_directory)
break
if len(split_arg) > 1:
if split_arg[0] == self.flag_directory:
self.directory = split_arg[1]
remove_args.append(arg)
self.args.append(self.flag_directory)
if split_arg[0] == self.flag_repository:
self.repository = split_arg[1]
remove_args.append(arg)
self.args.append(self.flag_repository)
try:
if arg.startswith(self.flag_short_directory):
if arg == self.flag_short_directory:
self.directory: str = self.args[self.args.index(arg) + 1]
self.args.remove(self.directory)
break
remove_args.append(self.directory)
except IndexError:
self.directory: Path = self.tmp_slpkg
if arg.startswith(self.flag_repository):
self.repository: str = arg.split('=')[1]
self.args.remove(arg)
self.args.append(self.flag_repository)
break
self.directory: str = ''
try:
if arg.startswith(self.flag_short_repository):
if arg == self.flag_short_repository:
self.repository: str = self.args[self.args.index(arg) + 1]
self.args.remove(self.repository)
break
remove_args.append(self.repository)
except IndexError:
self.repository: str = ''
for arg in remove_args:
if arg in self.args:
self.args.remove(arg)
def move_options(self) -> None:
""" Move options to the flags and removes from the arguments. """
new_args: list = []

View file

@ -32,7 +32,7 @@ class RepoInfo(Configs):
self.dates: dict = {}
self.option_for_repository: bool = self.utils.is_option(
('-o', '--repository='), flags)
('-o', '--repository'), flags)
def read_last_updated(self) -> dict:
last_updated_json: Path = Path(f'{self.repos.repositories_path}', self.repos.last_update_json)

View file

@ -37,7 +37,7 @@ class UpdateRepositories(Configs):
self.lftp_extra_options: str = ' '
self.option_for_repository: bool = self.utils.is_option(
('-o', '--repository='), flags)
('-o', '--repository'), flags)
def repositories(self) -> None:
self.repos_for_update: dict = self.check_updates.updates()