Skip to content

Commit

Permalink
add kibitzr stash command
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdemin committed Apr 20, 2018
1 parent 5d59cef commit 6824c12
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,11 @@

## Unreleased

## [5.1.1] - 2018-04-19

## Added
- `kibitzr stash` command to show stash contents.

## [5.1.0] - 2018-04-10

## Added
Expand Down
8 changes: 0 additions & 8 deletions HISTORY.rst

This file was deleted.

13 changes: 9 additions & 4 deletions docs/stash.rst
Expand Up @@ -8,15 +8,20 @@ Overview
--------

Kibitzr maintains persistent key-value storage - ``stash``.
All data inside ``stash`` is accessible inside all checks.
It is meant to be populated in notify.
Than it can be referred from :ref:`python-fetcher` and :ref:`jinja transform`.
All data inside ``stash`` is accessible inside all checks
and can be referred from :ref:`python-fetcher` and :ref:`jinja transform`.

Stash keys are populated in notifies.
Stash keys are populated in notify.
Use ``stash`` notifier and provide it key-value dictionary.
Each value is a Jinja template.
It has access to the same context as Jinja transform.

Stored values can be printed with command:

.. code-block:: shell
$ kibitzr stash
Example
-------

Expand Down
12 changes: 10 additions & 2 deletions kibitzr/cli.py
Expand Up @@ -64,8 +64,9 @@ def init():
@cli.command()
def telegram_chat():
"""Return chat id for the last message sent to Telegram Bot"""
from kibitzr.main import telegram_chat
telegram_chat()
# rename import to escape name clashing:
from kibitzr.main import telegram_chat as kilogram
kilogram()


@cli.command()
Expand All @@ -75,5 +76,12 @@ def clean():
PageHistory.clean()


@cli.command()
def stash():
"""Print stash contents"""
from kibitzr.stash import Stash
Stash.print_content()


if __name__ == "__main__":
cli()
5 changes: 5 additions & 0 deletions kibitzr/stash.py
Expand Up @@ -24,6 +24,11 @@ def write(self, data):
for key, value in data.items():
db[key] = value

@classmethod
def print_content(cls):
for key, value in cls().read().items():
print("{0}: {1}".format(key, value))


class LazyStash(Stash):
def __init__(self):
Expand Down

0 comments on commit 6824c12

Please sign in to comment.