# HG changeset patch # User Brian Neal # Date 1372972722 18000 # Node ID 1f5c0ae286a3bbbdbc4af1015aabe0d814d87234 # Parent 2eca19f50fdb4be379699ebcf10fdfe1bf90b438 Code review cleanup. diff -r 2eca19f50fdb -r 1f5c0ae286a3 m209/drum.py --- 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) diff -r 2eca19f50fdb -r 1f5c0ae286a3 m209/main.py --- 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. diff -r 2eca19f50fdb -r 1f5c0ae286a3 m209/procedure.py --- 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