mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Updated to class
This commit is contained in:
parent
d4daea3b2a
commit
32512a1547
2 changed files with 57 additions and 48 deletions
|
@ -41,7 +41,7 @@ from slpkg.health import PackageHealth
|
||||||
from slpkg.new_config import NewConfig
|
from slpkg.new_config import NewConfig
|
||||||
from slpkg.tracking import TrackingDeps
|
from slpkg.tracking import TrackingDeps
|
||||||
from slpkg.repoenable import RepoEnable
|
from slpkg.repoenable import RepoEnable
|
||||||
from slpkg.pkg_find import find_from_repos
|
from slpkg.pkg_find import FindFromRepos
|
||||||
from slpkg.arguments import options, usage
|
from slpkg.arguments import options, usage
|
||||||
from slpkg.slpkg_update import it_self_update
|
from slpkg.slpkg_update import it_self_update
|
||||||
from slpkg.status_deps import DependenciesStatus
|
from slpkg.status_deps import DependenciesStatus
|
||||||
|
@ -619,7 +619,7 @@ class ArgParse(object):
|
||||||
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:
|
||||||
find_from_repos(packages, flag)
|
FindFromRepos().find(packages, flag)
|
||||||
else:
|
else:
|
||||||
usage("")
|
usage("")
|
||||||
|
|
||||||
|
|
|
@ -28,52 +28,61 @@ from slpkg.pkg.manager import PackageManager
|
||||||
from slpkg.__metadata__ import MetaData as _meta_
|
from slpkg.__metadata__ import MetaData as _meta_
|
||||||
|
|
||||||
|
|
||||||
def find_from_repos(pkg, flag):
|
class FindFromRepos(object):
|
||||||
|
"""Find packages from all enabled repositories
|
||||||
"""
|
"""
|
||||||
Find packages from enabled repositories
|
def __init__(self):
|
||||||
"""
|
self.cache = ""
|
||||||
cache, p_cache, find_cache = "", "", ""
|
self.p_cache = ""
|
||||||
cyan = _meta_.color["CYAN"]
|
self.find_cache = ""
|
||||||
endc = _meta_.color["ENDC"]
|
self.count_pkg = 0
|
||||||
count_pkg = count_repo = 0
|
self.count_repo = 0
|
||||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
self.meta = _meta_
|
||||||
cyan, ", ".join(pkg), endc))
|
self.cyan = self.meta.color["CYAN"]
|
||||||
Msg().template(78)
|
self.grey = self.meta.color["GREY"]
|
||||||
print("| {0} {1}{2}{3}".format("Repository", "Package", " " * 54, "Size"))
|
self.endc = self.meta.color["ENDC"]
|
||||||
Msg().template(78)
|
|
||||||
for repo in _meta_.repositories:
|
|
||||||
PACKAGES_TXT = PackageManager(pkg).list_lib(repo)
|
|
||||||
packages, sizes = PackageManager(pkg).list_greps(repo, PACKAGES_TXT)
|
|
||||||
for find, size in zip(packages, sizes):
|
|
||||||
for p in pkg:
|
|
||||||
if "--case-ins" in flag:
|
|
||||||
p_cache = p.lower()
|
|
||||||
find_cache = find.lower()
|
|
||||||
else:
|
|
||||||
p_cache = p
|
|
||||||
find_cache = find
|
|
||||||
if p_cache in find_cache:
|
|
||||||
if cache != repo:
|
|
||||||
count_repo += 1
|
|
||||||
cache = repo
|
|
||||||
count_pkg += 1
|
|
||||||
ver = sbo_version(repo, find)
|
|
||||||
print(" {0}{1}{2}{3}{4} {5}{6:>11}".format(
|
|
||||||
cyan, repo, endc,
|
|
||||||
" " * (12 - len(repo)),
|
|
||||||
find + ver, " " * (53 - len(find + ver)),
|
|
||||||
size))
|
|
||||||
print("\nFound summary")
|
|
||||||
print("=" * 79)
|
|
||||||
print("{0}Total found {1} packages in {2} repositories.{3}\n".format(
|
|
||||||
_meta_.color["GREY"], count_pkg, count_repo, _meta_.color["ENDC"]))
|
|
||||||
|
|
||||||
|
def find(self, pkg, flag):
|
||||||
|
"""Start to find packages and print
|
||||||
|
"""
|
||||||
|
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||||
|
self.cyan, ", ".join(pkg), self.endc))
|
||||||
|
Msg().template(78)
|
||||||
|
print("| {0} {1}{2}{3}".format("Repository", "Package", " " * 54,
|
||||||
|
"Size"))
|
||||||
|
Msg().template(78)
|
||||||
|
for repo in _meta_.repositories:
|
||||||
|
PACKAGES_TXT = PackageManager(pkg).list_lib(repo)
|
||||||
|
packages, sizes = PackageManager(pkg).list_greps(repo, PACKAGES_TXT)
|
||||||
|
for find, size in zip(packages, sizes):
|
||||||
|
for p in pkg:
|
||||||
|
if "--case-ins" in flag:
|
||||||
|
self.p_cache = p.lower()
|
||||||
|
self.find_cache = find.lower()
|
||||||
|
else:
|
||||||
|
self.p_cache = p
|
||||||
|
self.find_cache = find
|
||||||
|
if self.p_cache in self.find_cache:
|
||||||
|
if self.cache != repo:
|
||||||
|
self.count_repo += 1
|
||||||
|
self.cache = repo
|
||||||
|
self.count_pkg += 1
|
||||||
|
ver = self.sbo_version(repo, find)
|
||||||
|
print(" {0}{1}{2}{3}{4} {5}{6:>11}".format(
|
||||||
|
self.cyan, repo, self.endc,
|
||||||
|
" " * (12 - len(repo)),
|
||||||
|
find + ver, " " * (53 - len(find + ver)),
|
||||||
|
size))
|
||||||
|
print("\nFound summary")
|
||||||
|
print("=" * 79)
|
||||||
|
print("{0}Total found {1} packages in {2} repositories.{3}\n".format(
|
||||||
|
self.grey, self.count_pkg, self.count_repo, self.endc))
|
||||||
|
|
||||||
def sbo_version(repo, find):
|
def sbo_version(self, repo, find):
|
||||||
"""
|
"""
|
||||||
Add version to SBo packages
|
Add version to SBo packages
|
||||||
"""
|
"""
|
||||||
ver = ""
|
ver = ""
|
||||||
if repo == "sbo":
|
if repo == "sbo":
|
||||||
ver = "-" + SBoGrep(find).version()
|
ver = "-" + SBoGrep(find).version()
|
||||||
return ver
|
return ver
|
||||||
|
|
Loading…
Reference in a new issue