changeset 50:1f5c0ae286a3

Code review cleanup.
author Brian Neal <bgneal@gmail.com>
date Thu, 04 Jul 2013 16:18:42 -0500
parents 2eca19f50fdb
children 9c994664fdd6
files m209/drum.py m209/main.py m209/procedure.py
diffstat 3 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/m209/drum.py	Thu Jul 04 15:30:19 2013 -0500
+++ b/m209/drum.py	Thu Jul 04 16:18:42 2013 -0500
@@ -127,8 +127,8 @@
 
         bars = sorted(cnt.items())
         if shortcut:
-            bars = ['{}-{}*{}'.format(p[0][0], p[0][1], p[1]) if p[1] > 1 else (
-                    '{}-{}'.format(p[0][0], p[0][1])) for p in bars]
+            bars = ['{}-{}*{}'.format(m, n, c) if c > 1 else (
+                    '{}-{}'.format(m, n)) for (m, n), c in bars]
         else:
             bars2 = []
             for p in bars:
@@ -136,7 +136,7 @@
                     bars2.append(p[0])
 
             bars2.extend([(0, 0)] * (27 - len(bars2)))
-            bars = ['{}-{}'.format(p[0], p[1]) for p in bars2]
+            bars = ['{}-{}'.format(m, n) for (m, n) in bars2]
 
         return ' '.join(bars)
 
--- a/m209/main.py	Thu Jul 04 15:30:19 2013 -0500
+++ b/m209/main.py	Thu Jul 04 16:18:42 2013 -0500
@@ -98,8 +98,8 @@
 def plaintext_filter(fp):
     """Generator function to filter input plaintext.
 
-    * ASCII upper case letters are passed as-is.
-    * ASCII lower case letters are converted to upper case.
+    * upper case letters are passed as-is.
+    * lower case letters are converted to upper case.
     * Whitespace characters are converted to 'Z'.
     * All other characters are dropped from the input.
 
--- a/m209/procedure.py	Thu Jul 04 15:30:19 2013 -0500
+++ b/m209/procedure.py	Thu Jul 04 16:18:42 2013 -0500
@@ -132,10 +132,9 @@
             ext_msg_ind = self.m_209.set_random_key_wheels()
 
         # Ensure we have a valid system indicator
-        if sys_ind:
-            if sys_ind not in M209_ALPHABET_SET:
-                raise ProcedureError("invalid system indicator {}".format(sys_ind))
-        else:
+        if sys_ind and sys_ind not in M209_ALPHABET_SET:
+            raise ProcedureError("invalid system indicator {}".format(sys_ind))
+        elif sys_ind is None:
             sys_ind = random.choice(M209_ALPHABET_LIST)
 
         # Generate internal message indicator
@@ -183,7 +182,7 @@
 
         """
         # See if we need to group the message.
-        if not ' ' in msg:
+        if ' ' not in msg:
             msg = group_text(msg)
 
         # Perform some basic checks on the message to see if it looks like an