Updated if statement

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-05-25 16:49:49 +03:00
parent 73903e783b
commit f1c474a550

View file

@ -101,9 +101,11 @@ class ArgParse(BlackList):
# checking if repositories exists
enabled_repos = _meta_.repositories
if len(self.args) > 1:
repo = self.args[1]
check = check_exists_repositories(repo)
if (len(self.args) > 1 and self.args[0] in options
and check is False and repo in enabled_repos):
print("\n Please update the packages lists. Run 'slpkg update'.\n"
@ -127,6 +129,7 @@ class ArgParse(BlackList):
"""Update package lists repositories
"""
update = Update()
if len(self.args) == 1 and self.args[0] == "update":
update.run(repos="")
elif (len(self.args) == 2 and self.args[0] == "update" and
@ -143,6 +146,7 @@ class ArgParse(BlackList):
"""Recreate repositories package lists
"""
upgrade = Upgrade()
if len(self.args) == 1 and self.args[0] == "upgrade":
upgrade.run(repos="")
elif (len(self.args) == 2 and self.args[0] == "upgrade" and
@ -224,9 +228,11 @@ class ArgParse(BlackList):
"""Print dependencies status
"""
image = ""
for arg in self.args:
if arg.startswith("--graph="):
image = arg.split("=")[1]
if len(self.args) == 1 and self.args[0] == "deps-status":
DependenciesStatus(image).show()
elif len(self.args) == 2 and self.args[0] == "deps-status" and image:
@ -274,8 +280,10 @@ class ArgParse(BlackList):
"-l",
"--list"
]
flag = ["--index", "--installed", "--name"]
name = INDEX = installed = False
for arg in self.args[2:]:
if flag[0] == arg:
INDEX = True
@ -285,6 +293,7 @@ class ArgParse(BlackList):
name = True
if arg not in flag:
usage("", 1)
if (len(self.args) > 1 and len(self.args) <= 5 and
self.args[0] in options):
if self.args[1] in self.meta.repositories:
@ -622,6 +631,7 @@ class ArgParse(BlackList):
if (additional_options[1] in self.args and
additional_options[0] not in self.args):
self.args.append(additional_options[0])
if len(self.args) > 1 and self.args[0] in options:
for additional in additional_options:
if additional in self.args:
@ -648,17 +658,21 @@ class ArgParse(BlackList):
"-f",
"--find"
]
additional_options = [
"--case-ins",
"--third-party"
]
for add in additional_options:
if add in self.args:
flag.append(add)
self.args.remove(add)
packages = self.args[1:]
if not packages:
packages = [""]
if len(self.args) == 1 and self.args[0] in options:
PackageManager(packages).find(flag)
elif len(self.args) > 1 and self.args[0] in options:
@ -673,7 +687,9 @@ class ArgParse(BlackList):
"-p",
"--desc"
]
flag = ["--color="]
colors = [
"red",
"green",
@ -681,14 +697,18 @@ class ArgParse(BlackList):
"cyan",
"grey"
]
tag = ""
for arg in self.args:
if arg.startswith(flag[0]):
tag = arg[len(flag[0]):]
self.args.remove(arg)
break
if tag and tag not in colors:
raise SystemExit(f"\nslpkg: Error: Available colors {colors}\n")
if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in self.meta.repositories and tag in colors):
PkgDesc(self.args[2], self.args[1], tag).view()
@ -710,11 +730,13 @@ class ArgParse(BlackList):
"--FIND"
]
additional_options = ["--case-ins"]
for arg in self.args:
if arg in additional_options:
flag.append(arg)
self.args.remove(arg)
packages = self.args[1:]
if len(self.args) > 1 and self.args[0] in options:
FindFromRepos().find(packages, flag)
else:
@ -728,6 +750,7 @@ class ArgParse(BlackList):
"-d",
"--display"
]
if len(self.args) > 1 and self.args[0] in options:
PackageManager(packages).display()
else:
@ -746,15 +769,15 @@ class ArgParse(BlackList):
"reset"
]
conf = Config()
if (len(self.args) == 2 and self.args[0] in options and
self.args[1] == command[1]):
conf.edit()
elif (len(self.args) == 2 and self.args[0] in options and
self.args[1] == (command[0])):
conf.view()
elif (len(self.args) == 2 and self.args[0] in options and
self.args[1] == (command[2])):
conf.reset()
if (len(self.args) == 2 and self.args[0] in options
and self.args[1] in options):
if self.args[1] == command[0]:
conf.view()
if self.args[1] == command[1]:
conf.edit()
if self.args[1] == command[2]:
conf.reset()
else:
usage("", 1)
@ -770,6 +793,7 @@ class ArgParse(BlackList):
if (not args[0].startswith("-") and args[0] not in self.commands and
args[0].endswith(tuple(suffixes))):
packages, not_found = [], []
for pkg in args:
if pkg.endswith(tuple(suffixes)):
if os.path.isfile(pkg):
@ -781,6 +805,7 @@ class ArgParse(BlackList):
if not_found:
for ntf in not_found:
self.msg.pkg_not_found("", ntf, "Not installed", "")
raise SystemExit(0)
def if_checklist(self):