Reformatted code base using black.

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

View file

@ -68,15 +68,15 @@ class UploadPlugin(object):
self._upload_callbacks = []
def _file_upload(
self, filepath, filename, upload_jid_s="", options='', profile=C.PROF_KEY_NONE
self, filepath, filename, upload_jid_s="", options="", profile=C.PROF_KEY_NONE
):
client = self.host.get_client(profile)
upload_jid = jid.JID(upload_jid_s) if upload_jid_s else None
options = data_format.deserialise(options)
return defer.ensureDeferred(self.file_upload(
client, filepath, filename or None, upload_jid, options
))
return defer.ensureDeferred(
self.file_upload(client, filepath, filename or None, upload_jid, options)
)
async def file_upload(self, client, filepath, filename, upload_jid, options):
"""Send a file using best available method
@ -87,10 +87,13 @@ class UploadPlugin(object):
"""
try:
progress_id, __ = await self.upload(
client, filepath, filename, upload_jid, options)
client, filepath, filename, upload_jid, options
)
except Exception as e:
if (isinstance(e, jabber_error.StanzaError)
and e.condition == 'not-acceptable'):
if (
isinstance(e, jabber_error.StanzaError)
and e.condition == "not-acceptable"
):
reason = e.text
else:
reason = str(e)
@ -110,7 +113,7 @@ class UploadPlugin(object):
filepath: Union[Path, str],
filename: Optional[str] = None,
upload_jid: Optional[jid.JID] = None,
extra: Optional[dict]=None
extra: Optional[dict] = None,
) -> Tuple[str, defer.Deferred]:
"""Send a file using best available method