Mercurial > libervia-backend
diff sat_frontends/jp/base.py @ 3600:1709f0a78f50
jp (base): add flag for `use_pubsub` to add cache skipping option
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 29 Jul 2021 22:51:01 +0200 |
parents | 5f65f4e9f8cb |
children | 51983c55c5b6 |
line wrap: on
line diff
--- a/sat_frontends/jp/base.py Thu Jul 29 22:51:01 2021 +0200 +++ b/sat_frontends/jp/base.py Thu Jul 29 22:51:01 2021 +0200 @@ -34,6 +34,7 @@ import termios from pathlib import Path from glob import iglob +from typing import Optional from importlib import import_module from sat_frontends.tools.jid import JID from sat.tools import config @@ -332,7 +333,7 @@ def make_pubsub_group(self, flags, defaults): - """generate pubsub options according to flags + """Generate pubsub options according to flags @param flags(iterable[unicode]): see [CommandBase.__init__] @param defaults(dict[unicode, unicode]): help text for default value @@ -402,7 +403,7 @@ help=_("find page before this item"), metavar='ITEM_ID') rsm_page_group.add_argument( "--index", dest="rsm_index", type=int, - help=_("index of the page to retrieve")) + help=_("index of the first item to retrieve")) # MAM @@ -424,6 +425,12 @@ C.ORDER_BY_MODIFICATION], help=_("how items should be ordered")) + if flags[C.CACHE]: + pubsub_group.add_argument( + "-C", "--no-cache", dest="use_cache", action='store_false', + help=_("don't use Pubsub cache") + ) + if not flags.all_used: raise exceptions.InternalError('unknown flags: {flags}'.format( flags=', '.join(flags.unused))) @@ -1235,6 +1242,16 @@ else: if order_by is not None: extra[C.KEY_ORDER_BY] = self.args.order_by + + # Cache + try: + use_cache = self.args.use_cache + except AttributeError: + pass + else: + if not use_cache: + extra[C.KEY_USE_CACHE] = use_cache + return data_format.serialise(extra) def add_parser_options(self):