Fix package deskcription

This commit is contained in:
Dimitris Zlatanidis 2015-09-18 02:19:12 +03:00
parent 0d3d1707fa
commit 6a3dc46f99
2 changed files with 14 additions and 20 deletions

View file

@ -26,6 +26,8 @@ from slpkg.utils import Utils
from slpkg.messages import Msg
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.sbo.greps import SBoGrep
class PkgDesc(object):
"""Print package description from the repository
@ -50,34 +52,26 @@ class PkgDesc(object):
if self.repo in self.meta.repositories and self.repo != "sbo":
self.lib = self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(
self.repo)
else:
self.lib = self.meta.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
self.repo)
def view(self):
"""Print package description by repository
"""
PACKAGES_TXT = Utils().read_file(self.lib)
print("") # new line at start
count = 0
if self.repo != "sbo":
description, count = "", 0
if self.repo == "sbo":
description = SBoGrep(self.name).description()
else:
PACKAGES_TXT = Utils().read_file(self.lib)
for line in PACKAGES_TXT.splitlines():
if line.startswith(self.name + ":"):
print("{0}{1}{2}".format(self.COLOR,
line[len(self.name) + 1:],
self.meta.color["ENDC"]))
description += line[len(self.name) + 2:] + "\n"
count += 1
if count == 11:
break
if description:
print("{0}{1}{2}".format(self.COLOR, description,
self.meta.color["ENDC"]))
else:
for line in PACKAGES_TXT.splitlines():
if (line.startswith(
"SLACKBUILD SHORT DESCRIPTION: " + self.name + " (")):
count += 1
print("{0}{1}{2}".format(self.COLOR,
line[31:],
self.meta.color["ENDC"]))
if count == 0:
self.msg.pkg_not_found("", self.name, "No matching", "\n")
else:
print("") # new line at end
if description and self.repo == "sbo":
print("")

View file

@ -45,7 +45,7 @@ from slpkg.sbo.compressed import SBoLink
from slpkg.sbo.search import sbo_search_pkg
from slpkg.sbo.slack_find import slack_package
from slack.slack_version import slack_ver
from slpkg.slack.slack_version import slack_ver
class SBoNetwork(object):