Use get instead of setdefault
authorPieter Lexis <pieter@plexis.eu>
Thu, 2 Feb 2012 16:48:56 +0000 (17:48 +0100)
committerPieter Lexis <pieter@plexis.eu>
Thu, 2 Feb 2012 16:48:56 +0000 (17:48 +0100)
swede

diff --git a/swede b/swede
index d7a6041d4f9dcd51966efa629a62b613d26091b6..ee5eaf3e853ae85c12c85b6998332baef258204e 100755 (executable)
--- a/swede
+++ b/swede
@@ -415,9 +415,9 @@ if __name__ == '__main__':
                        # First, check if the first three fields have correct values.
                        if not args.quiet:
                                print 'Received the following record for name %s:' % record.name
-                               print '\tUsage:\t\t\t\t%d (%s)' % (record.usage, {0:'CA Constraint', 1:'End-Entity Constraint', 2:'Trust Anchor'}.setdefault(record.usage, 'INVALID'))
-                               print '\tSelector:\t\t\t%d (%s)' % (record.selector, {0:'Certificate', 1:'SubjectPublicKeyInfo'}.setdefault(record.usage, 'INVALID'))
-                               print '\tMatching Type:\t\t\t%d (%s)' % (record.mtype, {0:'Full Certificate', 1:'SHA-256', 2:'SHA-512'}.setdefault(record.usage, 'INVALID'))
+                               print '\tUsage:\t\t\t\t%d (%s)' % (record.usage, {0:'CA Constraint', 1:'End-Entity Constraint', 2:'Trust Anchor'}.get(record.usage, 'INVALID'))
+                               print '\tSelector:\t\t\t%d (%s)' % (record.selector, {0:'Certificate', 1:'SubjectPublicKeyInfo'}.get(record.usage, 'INVALID'))
+                               print '\tMatching Type:\t\t\t%d (%s)' % (record.mtype, {0:'Full Certificate', 1:'SHA-256', 2:'SHA-512'}.get(record.usage, 'INVALID'))
                                print '\tCertificate for Association:\t%s' % record.cert
 
                        try: