From dc5600d306f808767068bad5117232fc3d35ac43 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Thu, 6 Dec 2018 01:50:52 +1100 Subject: [PATCH] python: examples * cut some of then poor len usage. --- lang/python/examples/howto/add-userid.py | 2 +- lang/python/examples/howto/create-key.py | 2 +- lang/python/examples/howto/revoke-userid.py | 2 +- lang/python/examples/howto/send-key-to-keyserver.py | 4 ++-- lang/python/examples/howto/sign-key.py | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lang/python/examples/howto/add-userid.py b/lang/python/examples/howto/add-userid.py index 85b90de5..945a8096 100755 --- a/lang/python/examples/howto/add-userid.py +++ b/lang/python/examples/howto/add-userid.py @@ -53,7 +53,7 @@ else: fpr = "".join(fpr0.split()) -if len(uid_cmnt) > 0: +if uid_cmnt: userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email) else: userid = "{0} <{2}>".format(uid_name, uid_email) diff --git a/lang/python/examples/howto/create-key.py b/lang/python/examples/howto/create-key.py index f7da2069..9058c194 100755 --- a/lang/python/examples/howto/create-key.py +++ b/lang/python/examples/howto/create-key.py @@ -52,7 +52,7 @@ elif os.path.exists(homedir) is True: else: pass -if len(uid_cmnt) > 0: +if uid_cmnt: userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email) else: userid = "{0} <{2}>".format(uid_name, uid_email) diff --git a/lang/python/examples/howto/revoke-userid.py b/lang/python/examples/howto/revoke-userid.py index ac5f6495..da84ad17 100755 --- a/lang/python/examples/howto/revoke-userid.py +++ b/lang/python/examples/howto/revoke-userid.py @@ -53,7 +53,7 @@ else: fpr = "".join(fpr0.split()) -if len(uid_cmnt) > 0: +if uid_cmnt: userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email) else: userid = "{0} <{2}>".format(uid_name, uid_email) diff --git a/lang/python/examples/howto/send-key-to-keyserver.py b/lang/python/examples/howto/send-key-to-keyserver.py index d72ca9f1..cb17e804 100755 --- a/lang/python/examples/howto/send-key-to-keyserver.py +++ b/lang/python/examples/howto/send-key-to-keyserver.py @@ -49,7 +49,7 @@ else: logrus = input("Enter the UID matching the key(s) to export: ") homedir = input("Enter the GPG configuration directory path (optional): ") -if len(homedir) == 0: +if not homedir: homedir = None elif homedir.startswith("~"): userdir = os.path.expanduser(homedir) @@ -73,7 +73,7 @@ if homedir is not None: else: pass -if len(logrus) > 0: +if logrus: try: export_result = c.key_export(pattern=logrus) except Exception as e: diff --git a/lang/python/examples/howto/sign-key.py b/lang/python/examples/howto/sign-key.py index 55d517b9..f9c90d76 100755 --- a/lang/python/examples/howto/sign-key.py +++ b/lang/python/examples/howto/sign-key.py @@ -53,11 +53,11 @@ else: fpr = "".join(fpr0.split()) key = c.get_key(fpr, secret=False) -if len(userid) > 0 and sig_type.lower() == "local": +if userid and sig_type.lower() == "local": c.key_sign(key, uids=userid, local=True) -elif len(userid) > 0 and sig_type.lower() != "local": +elif userid and sig_type.lower() != "local": c.key_sign(key, uids=userid) -elif len(userid) == 0 and sig_type.lower() == "local": +elif not userid and sig_type.lower() == "local": c.key_sign(key, local=True) else: c.key_sign(key)