Reformatted code base using black.

This commit is contained in:
Goffi 2024-06-19 18:44:57 +02:00
commit 53fdaa9d09

View file

@ -80,12 +80,10 @@ class Send(base.CommandBase):
"-e",
"--encrypt",
action="store_true",
help=_("end-to-end encrypt the file transfer")
help=_("end-to-end encrypt the file transfer"),
)
self.parser.add_argument(
"--webrtc",
action="store_true",
help=_("Use WebRTC Data Channel transport.")
"--webrtc", action="store_true", help=_("Use WebRTC Data Channel transport.")
)
async def on_progress_started(self, metadata):
@ -111,7 +109,6 @@ class Send(base.CommandBase):
self.disp(_("Can't send file to {jid}".format(jid=self.args.jid)), error=True)
self.host.quit(2)
async def start(self):
file_ = None
for file_ in self.args.files:
@ -170,17 +167,16 @@ class Send(base.CommandBase):
if self.verbosity >= 2:
root_logger.setLevel(logging.DEBUG)
from libervia.frontends.tools.webrtc_file import WebRTCFileSender
aio.install_glib_asyncio_iteration()
file_sender = WebRTCFileSender(
self.host.bridge,
self.profile,
on_call_start_cb=self.got_id,
end_call_cb=self.host.a_quit
end_call_cb=self.host.a_quit,
)
await file_sender.send_file_webrtc(
file_path,
self.args.jid,
self.args.name
file_path, self.args.jid, self.args.name
)
else:
try:
@ -319,7 +315,9 @@ class Receive(base.CommandAnswering):
use_verbose=True,
help=_("wait for a file to be sent by a contact"),
)
self._overwrite_refused = False # True when one overwrite has already been refused
self._overwrite_refused = (
False # True when one overwrite has already been refused
)
self.action_callbacks = {
C.META_TYPE_CONFIRM: self.on_confirm_action,
C.META_TYPE_FILE: self.on_file_action,
@ -377,12 +375,10 @@ class Receive(base.CommandAnswering):
await self.host.a_quit()
async def on_webrtc_file(
self,
from_jid: jid.JID,
session_id: str,
file_data: dict
self, from_jid: jid.JID, session_id: str, file_data: dict
) -> None:
from libervia.frontends.tools.webrtc_file import WebRTCFileReceiver
aio.install_glib_asyncio_iteration()
root_logger = logging.getLogger()
# we don't want any formatting for messages from webrtc
@ -401,29 +397,20 @@ class Receive(base.CommandAnswering):
filename = file_data.get("name", "unammed_file")
dest_path /= filename
if dest_path.exists() and not self.args.force:
self.host.disp(
"Destination file already exists",
error=True
)
self.host.disp("Destination file already exists", error=True)
aio.run_from_thread(
self.host.a_quit, C.EXIT_ERROR, loop=self.host.loop.loop
)
return
file_receiver = WebRTCFileReceiver(
self.host.bridge,
self.profile,
on_close_cb=self._on_webrtc_close
self.host.bridge, self.profile, on_close_cb=self._on_webrtc_close
)
await file_receiver.receive_file_webrtc(
from_jid,
session_id,
dest_path,
file_data
from_jid, session_id, dest_path, file_data
)
def get_xmlui_id(self, action_data):
# FIXME: we temporarily use ElementTree, but a real XMLUI managing module
# should be available in the futur
@ -482,8 +469,9 @@ class Receive(base.CommandAnswering):
if self._overwrite_refused:
self.disp(_("File refused because overwrite is needed"), error=True)
await self.host.bridge.action_launch(
xmlui_id, data_format.serialise({"cancelled": C.BOOL_TRUE}),
profile_key=profile
xmlui_id,
data_format.serialise({"cancelled": C.BOOL_TRUE}),
profile_key=profile,
)
return self.host.quit_from_signal(2)
await self.set_progress_id(progress_id)
@ -495,11 +483,7 @@ class Receive(base.CommandAnswering):
except KeyError:
self.disp(_("ignoring action without session id"), 1)
return
await self.on_webrtc_file(
from_jid,
session_id,
file_data
)
await self.on_webrtc_file(from_jid, session_id, file_data)
else:
xmlui_data = {"path": self.path}
@ -604,8 +588,9 @@ class Get(base.CommandBase):
help=_("overwrite existing file without confirmation"),
)
self.parser.add_argument(
"attachment", type=str,
help=_("URI of the file to retrieve or JSON of the whole attachment")
"attachment",
type=str,
help=_("URI of the file to retrieve or JSON of the whole attachment"),
)
async def on_progress_started(self, metadata):