1. Brian Neal
  2. enigma


Brian Neal  committed 1dac708

Added a get_rotor_count() method to EnigmaMachine.
Added a verbose option to pyenigma.py that calls it.

Comments (0)

Files changed (3)

File enigma/docs/source/reference.rst Modified

View file
  • Ignore whitespace
  • Hide word diff
       :rtype: string
+   .. method:: get_rotor_count()
+      Returns a list of integers that represent the rotation counts for each 
+      rotor. The rotation counts are reset to 0 every time :meth:`set_display`
+      is called.
    .. method:: key_press(key)
       Simulate a front panel key press. First the rotors are stepped by

File enigma/machine.py Modified

View file
  • Ignore whitespace
  • Hide word diff
         return ''.join(result)
+    def get_rotor_counts(self):
+        """Return the rotor rotation counts as a list of integers."""
+        return [r.rotations for r in self.rotors]

File enigma/main.py Modified

View file
  • Ignore whitespace
  • Hide word diff
             help=('if the input text contains chars not found on the enigma'
                   ' keyboard, delete them from the input'))
+    parser.add_argument('-v', '--verbose', action='store_true', default=False,
+            help='provide verbose output; include final rotor positions')
     args = parser.parse_args()
     s = machine.process_text(text, replace_char=replace_char)
+    if args.verbose:
+        print('Final rotor positions:', machine.get_display())
+        print('Rotor rotation counts:', machine.get_rotor_counts())
+        print('Output:')