From 1e17a6b2d7055cfc4d586c02e08059ca7e8eea6d Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 17 May 2015 00:59:06 +0300 Subject: [PATCH] feature added view version --- slpkg/binary/install.py | 12 ++++++++++++ slpkg/sbo/slackbuild.py | 2 +- slpkg/slack/patches.py | 15 +++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 22c0b028..47d32e4f 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -227,6 +227,16 @@ class BinaryInstall(object): if not self.if_upgrade: self.pkg_ver = [''] * len(packages) + def package_ver(self, package): + ''' + Return package version if package already installed + ''' + name = "-".join(package[:-4].split("-")[:-3]) + "-" + pkg = "".join(find_package(name, _m.pkg_path)[0]) + if pkg: + return split_package(pkg)[1] + return "" + def views(self, install, comp_sum, is_deps): ''' Views packages @@ -240,9 +250,11 @@ class BinaryInstall(object): for pkg, ver, comp in zip(install, self.pkg_ver, comp_sum): pkg_split = split_package(pkg[:-4]) if find_package(pkg[:-4], _m.pkg_path): + ver = '-' + self.package_ver(pkg) pkg_sum += 1 COLOR = _m.color['GREEN'] elif find_package(pkg_split[0] + "-", _m.pkg_path): + ver = '-' + self.package_ver(pkg) COLOR = _m.color['YELLOW'] upg_sum += 1 else: diff --git a/slpkg/sbo/slackbuild.py b/slpkg/sbo/slackbuild.py index 2b32931a..e13146e0 100644 --- a/slpkg/sbo/slackbuild.py +++ b/slpkg/sbo/slackbuild.py @@ -230,7 +230,7 @@ class SBoInstall(object): def package_ver(self, sbo): ''' - Return package version if package exist + Return package version if package already installed ''' pkg = "".join(find_package(sbo.split("-")[0] + "-", _m.pkg_path)) if pkg: diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index ec17e84a..cdfe7dc4 100644 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -145,6 +145,16 @@ class Patches(object): self.count_added += 1 self.count_upg -= 1 + def package_ver(self, package): + ''' + Return package version if package already installed + ''' + name = "-".join(package[:-4].split("-")[:-3]) + "-" + pkg = "".join(find_package(name, _m.pkg_path)[0]) + if pkg: + return split_package(pkg)[1] + return "" + def views(self): ''' Views packages @@ -152,11 +162,12 @@ class Patches(object): for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)): pkg_split = split_package(upg[:-4]) color = _m.color['YELLOW'] + ver = "-" + self.package_ver(upg) if not find_package(pkg_split[0], _m.pkg_path): color = _m.color['RED'] print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format( - color, pkg_split[0], _m.color['ENDC'], - " " * (24-len(pkg_split[0])), pkg_split[1], + color, pkg_split[0] + ver, _m.color['ENDC'], + " " * (24-len(pkg_split[0] + ver)), pkg_split[1], " " * (18-len(pkg_split[1])), pkg_split[2], " " * (8-len(pkg_split[2])), pkg_split[3], " " * (7-len(pkg_split[3])), "Slack",