# HG changeset patch # User Brian Neal # Date 1338855950 18000 # Node ID e328fcb6659b8e0d32e13c0563ac9df2914246a7 # Parent 1dac708e7b716846f0bd18f52fea4b8fa982dce5 Raise an exception if the requested day is not found in the key file. diff -r 1dac708e7b71 -r e328fcb6659b enigma/keyfile.py --- a/enigma/keyfile.py Mon Jun 04 19:22:55 2012 -0500 +++ b/enigma/keyfile.py Mon Jun 04 19:25:50 2012 -0500 @@ -76,4 +76,7 @@ settings['plugboard_settings'] = ' '.join(cols[-11:-1]) settings['reflector'] = cols[-1] + else: + raise KeyFileError('no entry for day %d found' % day) + return settings diff -r 1dac708e7b71 -r e328fcb6659b enigma/main.py --- a/enigma/main.py Mon Jun 04 19:22:55 2012 -0500 +++ b/enigma/main.py Mon Jun 04 19:25:50 2012 -0500 @@ -12,6 +12,7 @@ from .machine import EnigmaMachine, EnigmaError from .rotors import RotorError +from .keyfile import KeyFileError PROG_DESC = 'Encrypt/decrypt text according to Enigma machine key settings' @@ -132,7 +133,7 @@ def console_main(): try: main() - except (IOError, EnigmaError, RotorError) as ex: + except (IOError, EnigmaError, RotorError, KeyFileError) as ex: sys.stderr.write("%s\n" % ex)