python: examples
* cut some of then poor len usage.
This commit is contained in:
parent
1dffdcc6e9
commit
dc5600d306
@ -53,7 +53,7 @@ else:
|
|||||||
|
|
||||||
fpr = "".join(fpr0.split())
|
fpr = "".join(fpr0.split())
|
||||||
|
|
||||||
if len(uid_cmnt) > 0:
|
if uid_cmnt:
|
||||||
userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email)
|
userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email)
|
||||||
else:
|
else:
|
||||||
userid = "{0} <{2}>".format(uid_name, uid_email)
|
userid = "{0} <{2}>".format(uid_name, uid_email)
|
||||||
|
@ -52,7 +52,7 @@ elif os.path.exists(homedir) is True:
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if len(uid_cmnt) > 0:
|
if uid_cmnt:
|
||||||
userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email)
|
userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email)
|
||||||
else:
|
else:
|
||||||
userid = "{0} <{2}>".format(uid_name, uid_email)
|
userid = "{0} <{2}>".format(uid_name, uid_email)
|
||||||
|
@ -53,7 +53,7 @@ else:
|
|||||||
|
|
||||||
fpr = "".join(fpr0.split())
|
fpr = "".join(fpr0.split())
|
||||||
|
|
||||||
if len(uid_cmnt) > 0:
|
if uid_cmnt:
|
||||||
userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email)
|
userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email)
|
||||||
else:
|
else:
|
||||||
userid = "{0} <{2}>".format(uid_name, uid_email)
|
userid = "{0} <{2}>".format(uid_name, uid_email)
|
||||||
|
@ -49,7 +49,7 @@ else:
|
|||||||
logrus = input("Enter the UID matching the key(s) to export: ")
|
logrus = input("Enter the UID matching the key(s) to export: ")
|
||||||
homedir = input("Enter the GPG configuration directory path (optional): ")
|
homedir = input("Enter the GPG configuration directory path (optional): ")
|
||||||
|
|
||||||
if len(homedir) == 0:
|
if not homedir:
|
||||||
homedir = None
|
homedir = None
|
||||||
elif homedir.startswith("~"):
|
elif homedir.startswith("~"):
|
||||||
userdir = os.path.expanduser(homedir)
|
userdir = os.path.expanduser(homedir)
|
||||||
@ -73,7 +73,7 @@ if homedir is not None:
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if len(logrus) > 0:
|
if logrus:
|
||||||
try:
|
try:
|
||||||
export_result = c.key_export(pattern=logrus)
|
export_result = c.key_export(pattern=logrus)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -53,11 +53,11 @@ else:
|
|||||||
fpr = "".join(fpr0.split())
|
fpr = "".join(fpr0.split())
|
||||||
key = c.get_key(fpr, secret=False)
|
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)
|
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)
|
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)
|
c.key_sign(key, local=True)
|
||||||
else:
|
else:
|
||||||
c.key_sign(key)
|
c.key_sign(key)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user