Updated version from GetFromInstalled class

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-04-02 21:29:08 +03:00
parent b219415326
commit cb0324b9f6
7 changed files with 18 additions and 11 deletions

View file

@ -1399,7 +1399,7 @@ Check for the installed packages:
>>> GetFromInstalled(package="ffmpeg").name() >>> GetFromInstalled(package="ffmpeg").name()
'ffmpeg' 'ffmpeg'
>>> GetFromInstalled(package="ffmpeg").version() >>> GetFromInstalled(package="ffmpeg").version()
'-3.2.4' '3.2.4'
``` ```
##### Copyright ##### Copyright

View file

@ -244,7 +244,7 @@ class BinaryInstall(BlackList, Utils):
installed""" installed"""
name = split_package(package)[0] name = split_package(package)[0]
rep_ver = split_package(package)[1] rep_ver = split_package(package)[1]
ins_ver = GetFromInstalled(name).version()[1:] ins_ver = GetFromInstalled(name).version()
if not ins_ver: if not ins_ver:
ins_ver = "0" ins_ver = "0"
if parse_version(rep_ver) < parse_version(ins_ver): if parse_version(rep_ver) < parse_version(ins_ver):
@ -301,6 +301,8 @@ class BinaryInstall(BlackList, Utils):
COLOR = self.meta.color["RED"] COLOR = self.meta.color["RED"]
uni_sum += 1 uni_sum += 1
ver = GetFromInstalled(pkg_repo[0]).version() ver = GetFromInstalled(pkg_repo[0]).version()
if ver:
ver = f"-{ver}"
print(f" {COLOR}{pkg_repo[0] + ver}{self.endc}" print(f" {COLOR}{pkg_repo[0] + ver}{self.endc}"
f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}" f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}"
f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}" f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}"

View file

@ -46,7 +46,7 @@ class GetFromInstalled:
"""Return version from installed packages """Return version from installed packages
""" """
if self.find: if self.find:
return self.meta.sp + split_package(self.find)[1] return split_package(self.find)[1]
return "" return ""
def name(self): def name(self):

View file

@ -187,7 +187,8 @@ class PackageManager(Utils):
for pkg in self.binary: for pkg in self.binary:
name = GetFromInstalled(pkg).name() name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version() ver = GetFromInstalled(pkg).version()
package = find_package(f"{name}{ver}{self.meta.sp}", self.meta.pkg_path) package = find_package(f"{name}-{ver}{self.meta.sp}",
self.meta.pkg_path)
if pkg and name == pkg: if pkg and name == pkg:
removed.append(pkg) removed.append(pkg)
packages.append(package[0]) packages.append(package[0])
@ -257,7 +258,7 @@ class PackageManager(Utils):
for dep in dependencies: for dep in dependencies:
if GetFromInstalled(dep).name(): if GetFromInstalled(dep).name():
ver = GetFromInstalled(dep).version() ver = GetFromInstalled(dep).version()
packages.append(dep + ver) packages.append(f"{dep}-{ver}")
else: else:
dependencies.remove(dep) dependencies.remove(dep)
if packages: if packages:
@ -307,7 +308,7 @@ class PackageManager(Utils):
for dep in dependencies: for dep in dependencies:
if dep not in self.skip and GetFromInstalled(dep).name(): if dep not in self.skip and GetFromInstalled(dep).name():
ver = GetFromInstalled(dep).version() ver = GetFromInstalled(dep).version()
removes.append(dep + ver) removes.append(f"{dep}-{ver}")
self._removepkg(dep) self._removepkg(dep)
return removes return removes
@ -317,7 +318,7 @@ class PackageManager(Utils):
removes = [] removes = []
if GetFromInstalled(package).name() and package not in self.skip: if GetFromInstalled(package).name() and package not in self.skip:
ver = GetFromInstalled(package).version() ver = GetFromInstalled(package).version()
removes.append(package + ver) removes.append(f"{package}-{ver}")
self._removepkg(package) self._removepkg(package)
return removes return removes
@ -453,7 +454,7 @@ class PackageManager(Utils):
for pkg in self.binary: for pkg in self.binary:
name = GetFromInstalled(pkg).name() name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version() ver = GetFromInstalled(pkg).version()
find = find_package(f"{name}{ver}{self.meta.sp}", find = find_package(f"{name}-{ver}{self.meta.sp}",
self.meta.pkg_path) self.meta.pkg_path)
if find: if find:
package = self.read_file( package = self.read_file(

View file

@ -269,6 +269,8 @@ class SBoInstall(BlackList, Utils):
args[3] arch args[3] arch
""" """
ver = GetFromInstalled(args[1]).version() ver = GetFromInstalled(args[1]).version()
if ver:
ver = f"-{ver}"
print(f" {args[0]}{args[1] + ver} {self.endc}" print(f" {args[0]}{args[1] + ver} {self.endc}"
f"{' ' * (24-len(args[1] + ver))}{args[2]}" f"{' ' * (24-len(args[1] + ver))}{args[2]}"
f"{' ' * (18-len(args[2]))} {args[3]}" f"{' ' * (18-len(args[2]))} {args[3]}"
@ -372,7 +374,7 @@ class SBoInstall(BlackList, Utils):
installed""" installed"""
name = "-".join(prgnam.split("-")[:-1]) name = "-".join(prgnam.split("-")[:-1])
sbo_ver = prgnam.split("-")[-1] sbo_ver = prgnam.split("-")[-1]
ins_ver = GetFromInstalled(name).version()[1:] ins_ver = GetFromInstalled(name).version()
if not ins_ver: if not ins_ver:
ins_ver = "0" ins_ver = "0"
if parse_version(sbo_ver) < parse_version(ins_ver): if parse_version(sbo_ver) < parse_version(ins_ver):

View file

@ -142,7 +142,7 @@ class Patches(BlackList, Utils):
if (GetFromInstalled(pkg_name).name() and if (GetFromInstalled(pkg_name).name() and
repo_pkg_name not in black and repo_pkg_name not in black and
repo_pkg_name not in self.skip and repo_pkg_name not in self.skip and
pkg_ver > GetFromInstalled(pkg_name).version()[1:]): pkg_ver > GetFromInstalled(pkg_name).version()):
self.dwn_links.append(f"{mirrors('', '')}{loc}/{name}") self.dwn_links.append(f"{mirrors('', '')}{loc}/{name}")
self.comp_sum.append(comp) self.comp_sum.append(comp)
self.uncomp_sum.append(uncomp) self.uncomp_sum.append(uncomp)
@ -203,6 +203,8 @@ class Patches(BlackList, Utils):
if pkg_repo[0] == pkg_inst: if pkg_repo[0] == pkg_inst:
color = self.yellow color = self.yellow
ver = GetFromInstalled(pkg_repo[0]).version() ver = GetFromInstalled(pkg_repo[0]).version()
if ver:
ver = f"-{ver}"
print(f" {color}{pkg_repo[0] + ver}{self.endc}" print(f" {color}{pkg_repo[0] + ver}{self.endc}"
f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}" f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}"
f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}" f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}"

View file

@ -38,7 +38,7 @@ def choose_upg(packages):
for pkg in packages: for pkg in packages:
name = GetFromInstalled(pkg).name() name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version() ver = GetFromInstalled(pkg).version()
binary = f"{name}{ver}" binary = f"{name}-{ver}"
installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0] installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0]
data.append(installed) data.append(installed)
text = "Press 'spacebar' to unchoose packages from upgrade" text = "Press 'spacebar' to unchoose packages from upgrade"