comparison libervia/cli/cmd_avatar.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents 47401850dec6
children
comparison
equal deleted inserted replaced
4269:64a85ce8be70 4270:0d7bb4df2343
43 "--no-cache", action="store_true", help=_("do no use cached values") 43 "--no-cache", action="store_true", help=_("do no use cached values")
44 ) 44 )
45 self.parser.add_argument( 45 self.parser.add_argument(
46 "-s", "--show", action="store_true", help=_("show avatar") 46 "-s", "--show", action="store_true", help=_("show avatar")
47 ) 47 )
48 self.parser.add_argument("jid", nargs='?', default='', help=_("entity")) 48 self.parser.add_argument("jid", nargs="?", default="", help=_("entity"))
49 49
50 async def show_image(self, path): 50 async def show_image(self, path):
51 sat_conf = config.parse_main_conf() 51 sat_conf = config.parse_main_conf()
52 cmd = config.config_get(sat_conf, C.CONFIG_SECTION, "image_cmd") 52 cmd = config.config_get(sat_conf, C.CONFIG_SECTION, "image_cmd")
53 cmds = [cmd] + DISPLAY_CMD if cmd else DISPLAY_CMD 53 cmds = [cmd] + DISPLAY_CMD if cmd else DISPLAY_CMD
85 85
86 if not avatar_data: 86 if not avatar_data:
87 self.disp(_("No avatar found."), 1) 87 self.disp(_("No avatar found."), 1)
88 self.host.quit(C.EXIT_NOT_FOUND) 88 self.host.quit(C.EXIT_NOT_FOUND)
89 89
90 avatar_path = avatar_data['path'] 90 avatar_path = avatar_data["path"]
91 91
92 self.disp(avatar_path) 92 self.disp(avatar_path)
93 if self.args.show: 93 if self.args.show:
94 await self.show_image(avatar_path) 94 await self.show_image(avatar_path)
95 95
97 97
98 98
99 class Set(base.CommandBase): 99 class Set(base.CommandBase):
100 def __init__(self, host): 100 def __init__(self, host):
101 super(Set, self).__init__( 101 super(Set, self).__init__(
102 host, "set", use_verbose=True, 102 host,
103 help=_("set avatar of the profile or an entity") 103 "set",
104 use_verbose=True,
105 help=_("set avatar of the profile or an entity"),
104 ) 106 )
105 107
106 def add_parser_options(self): 108 def add_parser_options(self):
107 self.parser.add_argument( 109 self.parser.add_argument(
108 "-j", "--jid", default='', help=_("entity whose avatar must be changed")) 110 "-j", "--jid", default="", help=_("entity whose avatar must be changed")
111 )
109 self.parser.add_argument( 112 self.parser.add_argument(
110 "image_path", type=str, help=_("path to the image to upload") 113 "image_path", type=str, help=_("path to the image to upload")
111 ) 114 )
112 115
113 async def start(self): 116 async def start(self):