# HG changeset patch # User Brian Neal # Date 1338766522 18000 # Node ID 8347542c24a3deb7ce6045418d76cb388ab0400f # Parent dec8cd7da4d342a5e90a1a2b70923d7aeb382fa9 Added key_from_file to the user's guide. diff -r dec8cd7da4d3 -r 8347542c24a3 enigma/docs/source/guide.rst --- a/enigma/docs/source/guide.rst Sun Jun 03 17:33:43 2012 -0500 +++ b/enigma/docs/source/guide.rst Sun Jun 03 18:35:22 2012 -0500 @@ -102,6 +102,21 @@ words, these values produce identical ring settings: ``[0, 5, 15]``, ``'A F P'``, and ``'1 6 16'``. +The second shortcut function allows you to keep your key settings stored in an +external file:: + + from enigma.machine import EnigmaMachine + + with open('my_enigma_keys.txt', 'r') as f: + machine = EnigmaMachine.from_key_file(f, day=13) + +The class method :meth:`from_key_file +` builds an :class:`EnigmaMachine +` from settings stored in a simulated monthly key +sheet file. The format of this file is explained in :doc:`keyfile`. The ``day`` +argument allows you to specify the day of the month (1-31). If this parameter is +omitted or ``None``, the day value is obtained from the current date. + Constructing by hand ~~~~~~~~~~~~~~~~~~~~ @@ -252,7 +267,7 @@ plugboard_settings='AV BS CG DL FU HZ IN KM OW RX') Suppose the Enigma operator was handed a message for transmit by an officer -which reads "The Russians are coming!". The operator would first randomly decide +which reads "The Russians are coming!" The operator would first randomly decide two things: * Initial rotor positions, say ``WXC``