mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-21 19:27:47 +01:00
Updated if statement
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
parent
73903e783b
commit
f1c474a550
1 changed files with 34 additions and 9 deletions
|
@ -101,9 +101,11 @@ class ArgParse(BlackList):
|
||||||
|
|
||||||
# checking if repositories exists
|
# checking if repositories exists
|
||||||
enabled_repos = _meta_.repositories
|
enabled_repos = _meta_.repositories
|
||||||
|
|
||||||
if len(self.args) > 1:
|
if len(self.args) > 1:
|
||||||
repo = self.args[1]
|
repo = self.args[1]
|
||||||
check = check_exists_repositories(repo)
|
check = check_exists_repositories(repo)
|
||||||
|
|
||||||
if (len(self.args) > 1 and self.args[0] in options
|
if (len(self.args) > 1 and self.args[0] in options
|
||||||
and check is False and repo in enabled_repos):
|
and check is False and repo in enabled_repos):
|
||||||
print("\n Please update the packages lists. Run 'slpkg update'.\n"
|
print("\n Please update the packages lists. Run 'slpkg update'.\n"
|
||||||
|
@ -127,6 +129,7 @@ class ArgParse(BlackList):
|
||||||
"""Update package lists repositories
|
"""Update package lists repositories
|
||||||
"""
|
"""
|
||||||
update = Update()
|
update = Update()
|
||||||
|
|
||||||
if len(self.args) == 1 and self.args[0] == "update":
|
if len(self.args) == 1 and self.args[0] == "update":
|
||||||
update.run(repos="")
|
update.run(repos="")
|
||||||
elif (len(self.args) == 2 and self.args[0] == "update" and
|
elif (len(self.args) == 2 and self.args[0] == "update" and
|
||||||
|
@ -143,6 +146,7 @@ class ArgParse(BlackList):
|
||||||
"""Recreate repositories package lists
|
"""Recreate repositories package lists
|
||||||
"""
|
"""
|
||||||
upgrade = Upgrade()
|
upgrade = Upgrade()
|
||||||
|
|
||||||
if len(self.args) == 1 and self.args[0] == "upgrade":
|
if len(self.args) == 1 and self.args[0] == "upgrade":
|
||||||
upgrade.run(repos="")
|
upgrade.run(repos="")
|
||||||
elif (len(self.args) == 2 and self.args[0] == "upgrade" and
|
elif (len(self.args) == 2 and self.args[0] == "upgrade" and
|
||||||
|
@ -224,9 +228,11 @@ class ArgParse(BlackList):
|
||||||
"""Print dependencies status
|
"""Print dependencies status
|
||||||
"""
|
"""
|
||||||
image = ""
|
image = ""
|
||||||
|
|
||||||
for arg in self.args:
|
for arg in self.args:
|
||||||
if arg.startswith("--graph="):
|
if arg.startswith("--graph="):
|
||||||
image = arg.split("=")[1]
|
image = arg.split("=")[1]
|
||||||
|
|
||||||
if len(self.args) == 1 and self.args[0] == "deps-status":
|
if len(self.args) == 1 and self.args[0] == "deps-status":
|
||||||
DependenciesStatus(image).show()
|
DependenciesStatus(image).show()
|
||||||
elif len(self.args) == 2 and self.args[0] == "deps-status" and image:
|
elif len(self.args) == 2 and self.args[0] == "deps-status" and image:
|
||||||
|
@ -274,8 +280,10 @@ class ArgParse(BlackList):
|
||||||
"-l",
|
"-l",
|
||||||
"--list"
|
"--list"
|
||||||
]
|
]
|
||||||
|
|
||||||
flag = ["--index", "--installed", "--name"]
|
flag = ["--index", "--installed", "--name"]
|
||||||
name = INDEX = installed = False
|
name = INDEX = installed = False
|
||||||
|
|
||||||
for arg in self.args[2:]:
|
for arg in self.args[2:]:
|
||||||
if flag[0] == arg:
|
if flag[0] == arg:
|
||||||
INDEX = True
|
INDEX = True
|
||||||
|
@ -285,6 +293,7 @@ class ArgParse(BlackList):
|
||||||
name = True
|
name = True
|
||||||
if arg not in flag:
|
if arg not in flag:
|
||||||
usage("", 1)
|
usage("", 1)
|
||||||
|
|
||||||
if (len(self.args) > 1 and len(self.args) <= 5 and
|
if (len(self.args) > 1 and len(self.args) <= 5 and
|
||||||
self.args[0] in options):
|
self.args[0] in options):
|
||||||
if self.args[1] in self.meta.repositories:
|
if self.args[1] in self.meta.repositories:
|
||||||
|
@ -622,6 +631,7 @@ class ArgParse(BlackList):
|
||||||
if (additional_options[1] in self.args and
|
if (additional_options[1] in self.args and
|
||||||
additional_options[0] not in self.args):
|
additional_options[0] not in self.args):
|
||||||
self.args.append(additional_options[0])
|
self.args.append(additional_options[0])
|
||||||
|
|
||||||
if len(self.args) > 1 and self.args[0] in options:
|
if len(self.args) > 1 and self.args[0] in options:
|
||||||
for additional in additional_options:
|
for additional in additional_options:
|
||||||
if additional in self.args:
|
if additional in self.args:
|
||||||
|
@ -648,17 +658,21 @@ class ArgParse(BlackList):
|
||||||
"-f",
|
"-f",
|
||||||
"--find"
|
"--find"
|
||||||
]
|
]
|
||||||
|
|
||||||
additional_options = [
|
additional_options = [
|
||||||
"--case-ins",
|
"--case-ins",
|
||||||
"--third-party"
|
"--third-party"
|
||||||
]
|
]
|
||||||
|
|
||||||
for add in additional_options:
|
for add in additional_options:
|
||||||
if add in self.args:
|
if add in self.args:
|
||||||
flag.append(add)
|
flag.append(add)
|
||||||
self.args.remove(add)
|
self.args.remove(add)
|
||||||
packages = self.args[1:]
|
packages = self.args[1:]
|
||||||
|
|
||||||
if not packages:
|
if not packages:
|
||||||
packages = [""]
|
packages = [""]
|
||||||
|
|
||||||
if len(self.args) == 1 and self.args[0] in options:
|
if len(self.args) == 1 and self.args[0] in options:
|
||||||
PackageManager(packages).find(flag)
|
PackageManager(packages).find(flag)
|
||||||
elif len(self.args) > 1 and self.args[0] in options:
|
elif len(self.args) > 1 and self.args[0] in options:
|
||||||
|
@ -673,7 +687,9 @@ class ArgParse(BlackList):
|
||||||
"-p",
|
"-p",
|
||||||
"--desc"
|
"--desc"
|
||||||
]
|
]
|
||||||
|
|
||||||
flag = ["--color="]
|
flag = ["--color="]
|
||||||
|
|
||||||
colors = [
|
colors = [
|
||||||
"red",
|
"red",
|
||||||
"green",
|
"green",
|
||||||
|
@ -681,14 +697,18 @@ class ArgParse(BlackList):
|
||||||
"cyan",
|
"cyan",
|
||||||
"grey"
|
"grey"
|
||||||
]
|
]
|
||||||
|
|
||||||
tag = ""
|
tag = ""
|
||||||
|
|
||||||
for arg in self.args:
|
for arg in self.args:
|
||||||
if arg.startswith(flag[0]):
|
if arg.startswith(flag[0]):
|
||||||
tag = arg[len(flag[0]):]
|
tag = arg[len(flag[0]):]
|
||||||
self.args.remove(arg)
|
self.args.remove(arg)
|
||||||
break
|
break
|
||||||
|
|
||||||
if tag and tag not in colors:
|
if tag and tag not in colors:
|
||||||
raise SystemExit(f"\nslpkg: Error: Available colors {colors}\n")
|
raise SystemExit(f"\nslpkg: Error: Available colors {colors}\n")
|
||||||
|
|
||||||
if (len(self.args) == 3 and self.args[0] in options and
|
if (len(self.args) == 3 and self.args[0] in options and
|
||||||
self.args[1] in self.meta.repositories and tag in colors):
|
self.args[1] in self.meta.repositories and tag in colors):
|
||||||
PkgDesc(self.args[2], self.args[1], tag).view()
|
PkgDesc(self.args[2], self.args[1], tag).view()
|
||||||
|
@ -710,11 +730,13 @@ class ArgParse(BlackList):
|
||||||
"--FIND"
|
"--FIND"
|
||||||
]
|
]
|
||||||
additional_options = ["--case-ins"]
|
additional_options = ["--case-ins"]
|
||||||
|
|
||||||
for arg in self.args:
|
for arg in self.args:
|
||||||
if arg in additional_options:
|
if arg in additional_options:
|
||||||
flag.append(arg)
|
flag.append(arg)
|
||||||
self.args.remove(arg)
|
self.args.remove(arg)
|
||||||
packages = self.args[1:]
|
packages = self.args[1:]
|
||||||
|
|
||||||
if len(self.args) > 1 and self.args[0] in options:
|
if len(self.args) > 1 and self.args[0] in options:
|
||||||
FindFromRepos().find(packages, flag)
|
FindFromRepos().find(packages, flag)
|
||||||
else:
|
else:
|
||||||
|
@ -728,6 +750,7 @@ class ArgParse(BlackList):
|
||||||
"-d",
|
"-d",
|
||||||
"--display"
|
"--display"
|
||||||
]
|
]
|
||||||
|
|
||||||
if len(self.args) > 1 and self.args[0] in options:
|
if len(self.args) > 1 and self.args[0] in options:
|
||||||
PackageManager(packages).display()
|
PackageManager(packages).display()
|
||||||
else:
|
else:
|
||||||
|
@ -746,14 +769,14 @@ class ArgParse(BlackList):
|
||||||
"reset"
|
"reset"
|
||||||
]
|
]
|
||||||
conf = Config()
|
conf = Config()
|
||||||
if (len(self.args) == 2 and self.args[0] in options and
|
if (len(self.args) == 2 and self.args[0] in options
|
||||||
self.args[1] == command[1]):
|
and self.args[1] in options):
|
||||||
conf.edit()
|
|
||||||
elif (len(self.args) == 2 and self.args[0] in options and
|
if self.args[1] == command[0]:
|
||||||
self.args[1] == (command[0])):
|
|
||||||
conf.view()
|
conf.view()
|
||||||
elif (len(self.args) == 2 and self.args[0] in options and
|
if self.args[1] == command[1]:
|
||||||
self.args[1] == (command[2])):
|
conf.edit()
|
||||||
|
if self.args[1] == command[2]:
|
||||||
conf.reset()
|
conf.reset()
|
||||||
else:
|
else:
|
||||||
usage("", 1)
|
usage("", 1)
|
||||||
|
@ -770,6 +793,7 @@ class ArgParse(BlackList):
|
||||||
if (not args[0].startswith("-") and args[0] not in self.commands and
|
if (not args[0].startswith("-") and args[0] not in self.commands and
|
||||||
args[0].endswith(tuple(suffixes))):
|
args[0].endswith(tuple(suffixes))):
|
||||||
packages, not_found = [], []
|
packages, not_found = [], []
|
||||||
|
|
||||||
for pkg in args:
|
for pkg in args:
|
||||||
if pkg.endswith(tuple(suffixes)):
|
if pkg.endswith(tuple(suffixes)):
|
||||||
if os.path.isfile(pkg):
|
if os.path.isfile(pkg):
|
||||||
|
@ -781,6 +805,7 @@ class ArgParse(BlackList):
|
||||||
if not_found:
|
if not_found:
|
||||||
for ntf in not_found:
|
for ntf in not_found:
|
||||||
self.msg.pkg_not_found("", ntf, "Not installed", "")
|
self.msg.pkg_not_found("", ntf, "Not installed", "")
|
||||||
|
|
||||||
raise SystemExit(0)
|
raise SystemExit(0)
|
||||||
|
|
||||||
def if_checklist(self):
|
def if_checklist(self):
|
||||||
|
|
Loading…
Reference in a new issue