python: examples

* cut some of then poor len usage.
This commit is contained in:
Ben McGinnes 2018-12-06 01:50:52 +11:00
parent 1dffdcc6e9
commit dc5600d306
5 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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:

View File

@ -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)