From: Andrew Engelbrecht Date: Sun, 27 Jul 2014 05:49:25 +0000 (-0400) Subject: indentation changes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8bb4b0d50291a94cd1f379ec977a17763de133ac;p=edward.git indentation changes one function was hyper-indented. another didn't need nested indentation. --- diff --git a/edward-bot b/edward-bot index de03d4c..67adf2e 100755 --- a/edward-bot +++ b/edward-bot @@ -51,45 +51,46 @@ def main (): def msg_walk (msg): for part in msg.walk(): + if part.get_content_type() == 'multipart': continue - else: - filename = part.get_filename() - conttype = part.get_content_type() - descrip_p = part.get_params(header='content-description') - charset = part.get_content_charset() - payload_b = part.get_payload(decode=True) + filename = part.get_filename() + conttype = part.get_content_type() + descrip_p = part.get_params(header='content-description') - if payload_b == None: - continue + charset = part.get_content_charset() + payload_b = part.get_payload(decode=True) - if descrip_p == None: - decript = "" - else: - descript = descrip_p[0][0] + if payload_b == None: + continue - if charset == None: - charset = 'utf-8' + if descrip_p == None: + decript = "" + else: + descript = descrip_p[0][0] - payload = payload_b.decode(charset) + if charset == None: + charset = 'utf-8' - if conttype == "application/pgp-encrypted": - if descript == 'PGP/MIME version identification': - if payload.strip() != "Version: 1": - print("*** Warning... unknown pgp/mime version: " \ - + payload.strip()) - continue + payload = payload_b.decode(charset) - if (filename == "encrypted.asc") or (conttype == "pgp/mime"): - dec_msg = decrypt_payload(payload) - print_decrypted(dec_msg) + if conttype == "application/pgp-encrypted": + if descript == 'PGP/MIME version identification': + if payload.strip() != "Version: 1": + print("*** Warning... unknown pgp/mime version: " \ + + payload.strip()) + continue + + if (filename == "encrypted.asc") or (conttype == "pgp/mime"): + dec_msg = decrypt_payload(payload) + print_decrypted(dec_msg) - elif conttype == "text/plain": - print(payload) + elif conttype == "text/plain": + print(payload) - else: - print(payload) + else: + print(payload) def print_decrypted (message): @@ -107,41 +108,41 @@ def print_decrypted (message): def print_sig (sig): - fprint = sig.fpr - fprint_short = re.search("[0-9A-Fa-f]{32}([0-9A-Fa-f]{8})", fprint).groups()[0] + fprint = sig.fpr + fprint_short = re.search("[0-9A-Fa-f]{32}([0-9A-Fa-f]{8})", fprint).groups()[0] - timestamp = time.localtime(sig.timestamp) - date = time.strftime("%a %d %b %Y %I:%M:%S %p %Z", timestamp) + timestamp = time.localtime(sig.timestamp) + date = time.strftime("%a %d %b %Y %I:%M:%S %p %Z", timestamp) - g = gpgme.Context() - key = g.get_key(fprint) - - # right now i'm just choosing the first user id, even if that id isn't - # signed by the user yet another is. if a user id is printed, it should - # at least be one that is signed, and/or correspond to the From: - # field's email address and full name. - - name = key.uids[0].name - e_addr = key.uids[0].email - comment = key.uids[0].comment - - # this section needs some work. signature summary, validity, status, - # and wrong_key_usage all complicate the picture. their enum/#define - # values overlap, which makes things more complicated. - - validity = sig.validity - if validity == gpgme.VALIDITY_ULTIMATE \ - or validity == gpgme.VALIDITY_FULL: - status = "Good Signature " - elif validity == gpgme.VALIDITY_MARGINAL: - status = "Marginal Signature " - else: - status = "BAD Signature " + g = gpgme.Context() + key = g.get_key(fprint) + + # right now i'm just choosing the first user id, even if that id isn't + # signed by the user yet another is. if a user id is printed, it should + # at least be one that is signed, and/or correspond to the From: + # field's email address and full name. + + name = key.uids[0].name + e_addr = key.uids[0].email + comment = key.uids[0].comment + + # this section needs some work. signature summary, validity, status, + # and wrong_key_usage all complicate the picture. their enum/#define + # values overlap, which makes things more complicated. + + validity = sig.validity + if validity == gpgme.VALIDITY_ULTIMATE \ + or validity == gpgme.VALIDITY_FULL: + status = "Good Signature " + elif validity == gpgme.VALIDITY_MARGINAL: + status = "Marginal Signature " + else: + status = "BAD Signature " - print("Signature Made " + date + " using key ID " + fprint_short) - print(status + "from " + name + " (" + comment + ") <" \ - + e_addr + ">") + print("Signature Made " + date + " using key ID " + fprint_short) + print(status + "from " + name + " (" + comment + ") <" \ + + e_addr + ">") def decrypt_payload (payload):