# HG changeset patch # User Brian Neal # Date 1338176873 18000 # Node ID abf2132ad3388488bbdee1cb0acb29369916884e # Parent d46635a9f088e777dd86b73b64b4ec7882d05b8a Remove some unneeded conversions to string. Corrected Wehrmacht to Heer in a variable name. diff -r d46635a9f088 -r abf2132ad338 enigma/plugboard.py --- a/enigma/plugboard.py Sun May 27 22:20:58 2012 -0500 +++ b/enigma/plugboard.py Sun May 27 22:47:53 2012 -0500 @@ -13,7 +13,7 @@ # On Heer & Luftwaffe (?) models, the plugs are labeled with upper case letters -WEHRMACHT_LABELS = string.ascii_uppercase +HEER_LABELS = string.ascii_uppercase # The number of plugboard cables supplied with a machine: MAX_PAIRS = 10 @@ -114,7 +114,7 @@ m, n = p.split('/') m, n = int(m), int(n) except ValueError: - raise PlugboardError('invalid pair: %s' % str(p)) + raise PlugboardError('invalid pair: %s' % p) wiring_pairs.append((m - 1, n - 1)) else: @@ -123,12 +123,12 @@ for p in pairs: if len(p) != 2: - raise PlugboardError('invalid pair: %s' % str(p)) + raise PlugboardError('invalid pair: %s' % p) m = p[0] n = p[1] - if m not in WEHRMACHT_LABELS or n not in WEHRMACHT_LABELS: - raise PlugboardError('invalid pair: %s' % str(p)) + if m not in HEER_LABELS or n not in HEER_LABELS: + raise PlugboardError('invalid pair: %s' % p) wiring_pairs.append((ord(m) - ord('A'), ord(n) - ord('A'))) diff -r d46635a9f088 -r abf2132ad338 enigma/tests/test_plugboard.py --- a/enigma/tests/test_plugboard.py Sun May 27 22:20:58 2012 -0500 +++ b/enigma/tests/test_plugboard.py Sun May 27 22:47:53 2012 -0500 @@ -45,10 +45,12 @@ self.assertRaises(PlugboardError, Plugboard.from_key_sheet, '1*/26 17/4 21/6 3/16 19/14 22/3 8/1 12/25') self.assertRaises(PlugboardError, Plugboard.from_key_sheet, - '1*/26 17/4 2A/6 3/16 19/14 22/3 8/1 12/25') + '18/26 17/4 2A/6 3/16 19/14 22/3 8/1 12/25') self.assertRaises(PlugboardError, Plugboard.from_key_sheet, '100/2') self.assertRaises(PlugboardError, Plugboard.from_key_sheet, + '100') + self.assertRaises(PlugboardError, Plugboard.from_key_sheet, settings='T/C') def test_valid_settings(self):