mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-27 19:58:21 +01:00
Convert to class
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
parent
d729a683f5
commit
cb35d17182
4 changed files with 23 additions and 15 deletions
|
@ -37,7 +37,7 @@ from slpkg.log_deps import write_deps
|
|||
from slpkg.grep_md5 import pkg_checksum
|
||||
from slpkg.splitting import split_package
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
from slpkg.get_version import get_installed_version
|
||||
from slpkg.installed import GetFromInstalled
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
@ -223,7 +223,7 @@ class BinaryInstall(object):
|
|||
else:
|
||||
COLOR = self.meta.color["RED"]
|
||||
uni_sum += 1
|
||||
ver = get_installed_version(pkg_repo[0])
|
||||
ver = GetFromInstalled(pkg_repo[0]).version()
|
||||
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
|
||||
COLOR, pkg_repo[0] + ver, self.meta.color["ENDC"],
|
||||
" " * (23-len(pkg_repo[0] + ver)), pkg_repo[1],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*
|
||||
|
||||
# get_installed_version.py file is part of slpkg.
|
||||
# installed.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014-2015 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
@ -28,12 +28,20 @@ from __metadata__ import MetaData as _meta_
|
|||
from pkg.find import find_package
|
||||
|
||||
|
||||
def get_installed_version(package):
|
||||
"""Get version from installed packages
|
||||
class GetFromInstalled(object):
|
||||
"""Find and return version and package name from
|
||||
already installed packages
|
||||
"""
|
||||
find = find_package(package + _meta_.sp, _meta_.pkg_path)
|
||||
if find:
|
||||
name = split_package(find[0])[0]
|
||||
if package == name:
|
||||
return _meta_.sp + split_package(find[0])[1]
|
||||
return ""
|
||||
def __init__(self, package):
|
||||
self.package = package
|
||||
self.meta = _meta_
|
||||
|
||||
def version(self):
|
||||
"""Get version from installed packages
|
||||
"""
|
||||
find = find_package(self.package + _meta_.sp, _meta_.pkg_path)
|
||||
if find:
|
||||
name = split_package(find[0])[0]
|
||||
if self.package == name:
|
||||
return _meta_.sp + split_package(find[0])[1]
|
||||
return ""
|
|
@ -32,8 +32,8 @@ from slpkg.log_deps import write_deps
|
|||
from slpkg.blacklist import BlackList
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.splitting import split_package
|
||||
from slpkg.installed import GetFromInstalled
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
from slpkg.get_version import get_installed_version
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.build import BuildPackage
|
||||
|
@ -209,7 +209,7 @@ class SBoInstall(object):
|
|||
args[2] version
|
||||
args[3] arch
|
||||
"""
|
||||
ver = get_installed_version(args[1])
|
||||
ver = GetFromInstalled(args[1]).version()
|
||||
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
|
||||
args[0], args[1] + ver, self.meta.color["ENDC"],
|
||||
" " * (23-len(args[1] + ver)), args[2],
|
||||
|
|
|
@ -38,8 +38,8 @@ from slpkg.blacklist import BlackList
|
|||
from slpkg.downloader import Download
|
||||
from slpkg.grep_md5 import pkg_checksum
|
||||
from slpkg.splitting import split_package
|
||||
from slpkg.installed import GetFromInstalled
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
from slpkg.get_version import get_installed_version
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
@ -163,7 +163,7 @@ class Patches(object):
|
|||
pkg_inst = self.find_installed(pkg_repo[0])
|
||||
if pkg_repo[0] == pkg_inst:
|
||||
color = self.meta.color["YELLOW"]
|
||||
ver = get_installed_version(pkg_repo[0])
|
||||
ver = GetFromInstalled(pkg_repo[0]).version()
|
||||
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format(
|
||||
color, pkg_repo[0] + ver, self.meta.color["ENDC"],
|
||||
" " * (23-len(pkg_repo[0] + ver)), pkg_repo[1],
|
||||
|
|
Loading…
Add table
Reference in a new issue