port_stats.interactive update

- update docstring
- add stats() function
- rename grep_spi -> gspi to save some typing
This commit is contained in:
Ivan A. Melnikov 2018-08-14 14:11:50 +04:00
parent 020a5d34a2
commit 08af75a9b9

View File

@ -3,20 +3,21 @@
What's in the box:
- load_tasks() -- (re)loads the task information from prefix
- load_colors() -- (re)loads the packages from srclists and colorizes them
- load_all() -- (re)loads both tasks and packages
- load() -- (re)loads the task and packages information
- use(repo) -- switch to using <repo>
- load(repo) -- load stuff and start using the given repo instead of default
- pt(name) -- prints information about the package tasks
- spt(name) -- prints information about the package tasks, short version
- spi(name) -- prints the short package information
- grep_spi(pattern) -- prints the short package information
all the packages with name matching pattern
- list_spi(pkgs_list) -- same as grep_spi, but for python lists
- gspi(pattern) -- prints the short package information for
all the packages with name matching pattern ('g' for 'grep')
- list_spi(pkgs_list) -- same as gspi, but for python lists
of strings instead of patterns
- ti(num) -- prints information about the task #num
- fti(num) -- prints information about the task #num, full version (a dict)
- logs(num, [idx]) -- print logs (logs/events.X.Y.log) for task #num
- next_tasks() -- display all non-done tasks that would update packages
- stats() -- prints packages statistics
You can also enjoy autocompletion with <TAB>.
"""
@ -142,7 +143,7 @@ def _spi_by_predicate(pred, colors, to):
to(lines)
def grep_spi(pattern, colors=None, to=print):
def gspi(pattern, colors=None, to=print):
p = re.compile(pattern)
_spi_by_predicate(p.search, colors, to)
@ -196,6 +197,11 @@ def logs(num, idx=-1, to=pager):
to(log_file + ':\n\n' + log)
def stats(to=dump):
to('\n'.join('%10s:%6s' % (color, len(BY_COLOR[color]))
for color in colorize.COLORS))
def interactive_setup():
# Bind TAB to complete
readline.parse_and_bind('tab:complete')