Fix remove dependencies if exist

This commit is contained in:
Dimitris Zlatanidis 2015-09-11 05:48:05 +03:00
parent 497d16f63f
commit cf38f936fe

View file

@ -117,7 +117,8 @@ class PackageManager(object):
if (os.path.isfile(self.dep_path + rmv) and
self.meta.del_deps in ["on", "ON"]):
dependencies = self._view_deps(self.dep_path, rmv)
if self._rmv_deps_answer() in ["y", "Y"]:
if dependencies and self._rmv_deps_answer() in ["y",
"Y"]:
rmv_list += self._rmv_deps(dependencies, rmv)
else:
rmv_list += self._rmv_pkg(rmv)
@ -217,7 +218,7 @@ class PackageManager(object):
self.meta.color["ENDC"]))
def _view_deps(self, path, package):
"""View dependencies for before remove
"""View dependencies before remove
"""
self.size = 0
packages = []
@ -226,36 +227,38 @@ class PackageManager(object):
if GetFromInstalled(dep).name():
ver = GetFromInstalled(dep).version()
packages.append(dep + ver)
if "--checklist" in self.extra:
deps, dependencies = [], ""
data = packages
text = "Found dependencies for package {0}".format(package)
title = "Remove"
backtitle = "{0} {1}".format(self.meta.__all__,
self.meta.__version__)
status = True
deps = DialogUtil(data, text, title, backtitle, status).checklist()
for d in deps:
dependencies += " " + "-".join(d.split("-")[:-1])
dependencies = dependencies.strip()
self.meta.remove_deps_answer = "y"
else:
print("") # new line at start
self.msg.template(78)
print("| Found dependencies for package {0}:".format(package))
self.msg.template(78)
for pkg in packages:
find = find_package(pkg + self.meta.sp, self.meta.pkg_path)
self._sizes(find[0])
print("| {0}{1}{2}".format(self.meta.color["RED"], pkg,
self.meta.color["ENDC"]))
self.msg.template(78)
self._calc_sizes()
print("| {0}Size of removed dependencies {1} {2}{3}".format(
self.meta.color["GREY"], round(self.size, 2), self.unit,
self.meta.color["ENDC"]))
self.msg.template(78)
return dependencies
if packages:
if "--checklist" in self.extra:
deps, dependencies = [], ""
data = packages
text = "Found dependencies for package {0}".format(package)
title = "Remove"
backtitle = "{0} {1}".format(self.meta.__all__,
self.meta.__version__)
status = True
deps = DialogUtil(data, text, title, backtitle,
status).checklist()
for d in deps:
dependencies += " " + "-".join(d.split("-")[:-1])
dependencies = dependencies.strip()
self.meta.remove_deps_answer = "y"
else:
print("") # new line at start
self.msg.template(78)
print("| Found dependencies for package {0}:".format(package))
self.msg.template(78)
for pkg in packages:
find = find_package(pkg + self.meta.sp, self.meta.pkg_path)
self._sizes(find[0])
print("| {0}{1}{2}".format(self.meta.color["RED"], pkg,
self.meta.color["ENDC"]))
self.msg.template(78)
self._calc_sizes()
print("| {0}Size of removed dependencies {1} {2}{3}".format(
self.meta.color["GREY"], round(self.size, 2), self.unit,
self.meta.color["ENDC"]))
self.msg.template(78)
return dependencies
def _removepkg(self, package):
"""removepkg Slackware command