From 4a1421bb04c6732c42b260781db6a8fc7db42894 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 14 Sep 2015 04:20:58 +0300 Subject: [PATCH] Added additional option '--checklist' --- ChangeLog.txt | 4 +++- README.rst | 23 +++++++++++++++++++++++ man/slpkg.8 | 9 +++++++-- slpkg/main.py | 7 ++++++- slpkg/sbo/network.py | 37 ++++++++++++++++++++++++++++++++++--- 5 files changed, 73 insertions(+), 7 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b42dfe04..643ad8d8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,6 @@ -2.8.8 - 13/09/2015 +2.8.8 - 14/09/2015 +Added: +- Additional option "--checklist" in "-n, --network" option Fixed: - Typo in help option Updated: diff --git a/README.rst b/README.rst index 54e2e25b..1d5db7c4 100644 --- a/README.rst +++ b/README.rst @@ -1078,6 +1078,29 @@ Read fies, download, build or install: +================================================================================ Choose an option > _ + +Use dialog utility to help you find a package: + +.. code-block:: bash + + Load all repository: + + $ slpkg -n ALL --checklist + Reading package lists... + +.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/pythondialog5.png + :target: https://github.com/dslackw/slpkg + +.. code-block:: bash + + Search from pattern such as all 'perl' packages: + + $ slpkg -n perl --checklist + Reading package lists... + +.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/pythondialog6.png + :target: https://github.com/dslackw/slpkg + Auto tool to build package: diff --git a/man/slpkg.8 b/man/slpkg.8 index 87b4363e..f1f11735 100644 --- a/man/slpkg.8 +++ b/man/slpkg.8 @@ -253,10 +253,15 @@ Find installed packages with view total file size. Example you can view all installed sbo packages like "# slpkg -f _SBo". .SS -n, --network, view SBo packages -\fBslpkg\fP \fB-n\fP <\fIname of package\fP> +\fBslpkg\fP \fB-n\fP <\fIname of package\fP>, <\fI[pattern] --checklist\fP> .PP View complete slackbuilds.org site in your terminal. Read file, download, -build or install etc. +build or install etc. Use 'ALL' in [pattern] and "--checklist" additional option to load all +repository, example "slpkg -n ALL --checklist". +.PP +Additional options: +.PP +\fB--checklist\fP : Enable dialog utility and checklist option. (Require python2-pythondialog) .SS -i, --installpkg, install Slackware binary packages \fBslpkg\fP \fB-i\fP \fB[--warn, --md5sum, --root /otherroot, --infobox, --menu, --terse, diff --git a/slpkg/main.py b/slpkg/main.py index a655c656..6ba8f808 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -347,10 +347,15 @@ class ArgParse(object): def sbo_network(self): """View slackbuilds packages """ + flag = [] options = ["-n", "--network"] + additional_options = ["--checklist"] + if self.args[-1] in additional_options: + flag.append(additional_options[0]) + self.args.remove(additional_options[0]) if (len(self.args) == 2 and self.args[0] in options and "sbo" in self.meta.repositories): - SBoNetwork(self.args[1]).view() + SBoNetwork(self.args[1], flag).view() else: usage("sbo") diff --git a/slpkg/sbo/network.py b/slpkg/sbo/network.py index 34b065bf..9cacbb60 100644 --- a/slpkg/sbo/network.py +++ b/slpkg/sbo/network.py @@ -39,6 +39,7 @@ from slpkg.sbo.read import ReadSBo from slpkg.sbo.remove import delete from slpkg.sbo.greps import SBoGrep from slpkg.sbo.sbo_arch import SBoArch +from slpkg.dialog_box import DialogUtil from slpkg.sbo.compressed import SBoLink from slpkg.sbo.search import sbo_search_pkg from slpkg.sbo.slack_find import slack_package @@ -48,8 +49,9 @@ class SBoNetwork(object): """View SBo site in terminal and also read, build or install packages """ - def __init__(self, name): + def __init__(self, name, flag): self.name = name + self.flag = flag self.meta = _meta_ self.msg = Msg() self.arch = SBoArch().get() @@ -64,8 +66,10 @@ class SBoNetwork(object): self.endc = self.meta.color["ENDC"] self.build_folder = self.meta.build_path self.msg.reading() - grep = SBoGrep(self.name) self.data = SBoGrep(name="").names() + if "--checklist" in self.flag: + self.with_checklist() + grep = SBoGrep(self.name) self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo") self.sbo_url = sbo_search_pkg(self.name) if self.sbo_url: @@ -75,7 +79,8 @@ class SBoNetwork(object): self.sbo_dwn = SBoLink(self.sbo_url).tar_gz() self.sbo_version = grep.version() self.dwn_srcs = self.sbo_dwn.split() + self.source_dwn - self.msg.done() + if "--checklist" not in self.flag or not self.sbo_url: + self.msg.done() def view(self): """View SlackBuild package, read or install them @@ -257,6 +262,32 @@ class SBoNetwork(object): self.msg.template(78) + def with_checklist(self): + """Using dialog and checklist option + """ + data = [] + try: + if self.name == "ALL": + data = self.data + else: + for name in self.data: + if self.name in name: + data.append(name) + except KeyboardInterrupt: + print("") + raise SystemExit() + if data: + text = "Press 'spacebar' to choose SlackBuild for view" + title = "SlackBuilds.org" + backtitle = "{0} {1}".format(_meta_.__all__, _meta_.__version__) + status = False + pkg = DialogUtil(data, text, title, backtitle, status).checklist() + if len(pkg) > 1: + print("\nslpkg: error: choose only one package") + raise SystemExit() + self.name = "".join(pkg) + os.system("clear") + def pager(self, text): """Read text """