From 294fc73ce1acbe1084eda2db369b30a855e88b93 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Oct 2014 18:38:48 +0200 Subject: [PATCH] update code --- slpkg/main.py | 1 + slpkg/sbo/views.py | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index 453db755..4a5ddb7f 100755 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -52,6 +52,7 @@ def main(): repository = ["sbo", "slack"] blacklist = BlackList() queue = QueuePkgs() + if len(args) == 0: usage() elif (len(args) == 1 and args[0] == "-h" or diff --git a/slpkg/sbo/views.py b/slpkg/sbo/views.py index a7fdbf79..04acc2df 100755 --- a/slpkg/sbo/views.py +++ b/slpkg/sbo/views.py @@ -56,6 +56,7 @@ class SBoNetwork(object): self.source_dwn = grep.source().split() self.sbo_dwn = SBoLink(self.sbo_url).tar_gz() self.sbo_version = grep.version() + self.space = ("\n" * 50) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) def view(self): @@ -76,12 +77,18 @@ class SBoNetwork(object): download("", self.sbo_dwn, self.source_dwn) break elif choice in ["R", "r"]: - pydoc.pager(Read(self.sbo_url).readme("README")) + README = Read(self.sbo_url).readme("README") + fill = fill_pager(README) + pydoc.pager(README + fill) elif choice in ["F", "f"]: - pydoc.pager(Read(self.sbo_url).info(self.name, ".info")) + info = Read(self.sbo_url).info(self.name, ".info") + fill = fill_pager(info) + pydoc.pager(info + fill) elif choice in ["S", "s"]: - pydoc.pager(Read(self.sbo_url).slackbuild(self.name, - ".SlackBuild")) + SlackBuild = Read(self.sbo_url).slackbuild(self.name, + ".SlackBuild") + fill = fill_pager(SlackBuild) + pydoc.pager(SlackBuild + fill) elif choice in ["B", "b"]: build(self.sbo_dwn, self.source_dwn, FAULT) break @@ -101,6 +108,22 @@ class SBoNetwork(object): pkg_not_found("\n", self.name, "Can't view", "\n") +def fill_pager(page): + ''' + Fix pager spaces + ''' + rows, columns = os.popen('stty size', 'r').read().split() + lines = 1 + for line in page.splitlines(): + lines += 1 + diff = int(rows) - lines + fill = "\n" * diff + if diff > 0: + return fill + else: + return "" + + def read_choice(): ''' Return choice