comparison sat_frontends/jp/base.py @ 3938:6939594ba77e

cli (pubsub/get): add `--no-decrypt` flag to disable automatic decryption: rel 380
author Goffi <goffi@goffi.org>
date Sat, 15 Oct 2022 20:37:00 +0200
parents 045af0eeda3f
children 524856bd7b19
comparison
equal deleted inserted replaced
3937:5980ea188f87 3938:6939594ba77e
32 import inspect 32 import inspect
33 import tty 33 import tty
34 import termios 34 import termios
35 from pathlib import Path 35 from pathlib import Path
36 from glob import iglob 36 from glob import iglob
37 from typing import Optional, Set 37 from typing import Optional, Set, Union
38 from importlib import import_module 38 from importlib import import_module
39 from sat_frontends.tools.jid import JID 39 from sat_frontends.tools.jid import JID
40 from sat.tools import config 40 from sat.tools import config
41 from sat.tools.common import dynamic_import 41 from sat.tools.common import dynamic_import
42 from sat.tools.common import uri 42 from sat.tools.common import uri
977 "JabberID", "Connection", profile_key=self.profile 977 "JabberID", "Connection", profile_key=self.profile
978 ) 978 )
979 return full_jid.rsplit("/", 1)[0] 979 return full_jid.rsplit("/", 1)[0]
980 980
981 981
982 class CommandBase(object): 982 class CommandBase:
983 983
984 def __init__(self, host, name, use_profile=True, use_output=False, extra_outputs=None, 984 def __init__(
985 need_connect=None, help=None, **kwargs): 985 self,
986 host: LiberviaCli,
987 name: str,
988 use_profile: bool = True,
989 use_output: Union[bool, str] = False,
990 extra_outputs: Optional[dict] = None,
991 need_connect: Optional[bool] = None,
992 help: Optional[str] = None,
993 **kwargs
994 ):
986 """Initialise CommandBase 995 """Initialise CommandBase
987 996
988 @param host: Jp instance 997 @param host: Jp instance
989 @param name(unicode): name of the new command 998 @param name: name of the new command
990 @param use_profile(bool): if True, add profile selection/connection commands 999 @param use_profile: if True, add profile selection/connection commands
991 @param use_output(bool, unicode): if not False, add --output option 1000 @param use_output: if not False, add --output option
992 @param extra_outputs(dict): list of command specific outputs: 1001 @param extra_outputs: list of command specific outputs:
993 key is output name ("default" to use as main output) 1002 key is output name ("default" to use as main output)
994 value is a callable which will format the output (data will be used as only 1003 value is a callable which will format the output (data will be used as only
995 argument) 1004 argument)
996 if a key already exists with normal outputs, the extra one will be used 1005 if a key already exists with normal outputs, the extra one will be used
997 @param need_connect(bool, None): True if profile connection is needed 1006 @param need_connect: True if profile connection is needed
998 False else (profile session must still be started) 1007 False else (profile session must still be started)
999 None to set auto value (i.e. True if use_profile is set) 1008 None to set auto value (i.e. True if use_profile is set)
1000 Can't be set if use_profile is False 1009 Can't be set if use_profile is False
1001 @param help(unicode): help message to display 1010 @param help: help message to display
1002 @param **kwargs: args passed to ArgumentParser 1011 @param **kwargs: args passed to ArgumentParser
1003 use_* are handled directly, they can be: 1012 use_* are handled directly, they can be:
1004 - use_progress(bool): if True, add progress bar activation option 1013 - use_progress(bool): if True, add progress bar activation option
1005 progress* signals will be handled 1014 progress* signals will be handled
1006 - use_verbose(bool): if True, add verbosity option 1015 - use_verbose(bool): if True, add verbosity option