diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2022-03-17 20:56:03 +0100 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2022-03-19 10:31:34 +0100 |
commit | 54b724c28b1048d8508f1523693d4f7df340fc13 (patch) | |
tree | ccbbb921182387f88790dde8cd98557e77529bfb /examples | |
parent | abd699593f53ec89b57d697296a6526bcfad7a8d (diff) | |
download | slixmpp-54b724c28b1048d8508f1523693d4f7df340fc13.tar.gz slixmpp-54b724c28b1048d8508f1523693d4f7df340fc13.tar.bz2 slixmpp-54b724c28b1048d8508f1523693d4f7df340fc13.tar.xz slixmpp-54b724c28b1048d8508f1523693d4f7df340fc13.zip |
examples/http_upload: Add some typing
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/http_upload.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/examples/http_upload.py b/examples/http_upload.py index a926fd47..cac8fc7e 100755 --- a/examples/http_upload.py +++ b/examples/http_upload.py @@ -5,11 +5,15 @@ # This file is part of Slixmpp. # See the file LICENSE for copying permission. +from typing import Optional + import logging +from pathlib import Path from getpass import getpass from argparse import ArgumentParser import slixmpp +from slixmpp import JID from slixmpp.exceptions import IqTimeout log = logging.getLogger(__name__) @@ -21,7 +25,14 @@ class HttpUpload(slixmpp.ClientXMPP): A basic client asking an entity if they confirm the access to an HTTP URL. """ - def __init__(self, jid, password, recipient, filename, domain=None): + def __init__( + self, + jid: JID, + password: str, + recipient: JID, + filename: Path, + domain: Optional[JID] = None, + ): slixmpp.ClientXMPP.__init__(self, jid, password) self.recipient = recipient @@ -86,11 +97,21 @@ if __name__ == '__main__': format='%(levelname)-8s %(message)s') if args.jid is None: - args.jid = input("Username: ") + args.jid = JID(input("Username: ")) if args.password is None: args.password = getpass("Password: ") - xmpp = HttpUpload(args.jid, args.password, args.recipient, args.file, args.domain) + domain = args.domain + if domain is not None: + domain = JID(domain) + + xmpp = HttpUpload( + jid=args.jid, + password=args.password, + recipient=JID(args.recipient), + filename=Path(args.file), + domain=domain, + ) xmpp.register_plugin('xep_0066') xmpp.register_plugin('xep_0071') xmpp.register_plugin('xep_0128') |