Added additional option '--checklist'

This commit is contained in:
Dimitris Zlatanidis 2015-09-14 04:20:58 +03:00
parent b6f12bc6b9
commit 4a1421bb04
5 changed files with 73 additions and 7 deletions

View file

@ -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:

View file

@ -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:

View file

@ -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,

View file

@ -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")

View file

@ -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
"""