Mercurial > public > enigma
changeset 39:e328fcb6659b
Raise an exception if the requested day is not found in the key file.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 04 Jun 2012 19:25:50 -0500 |
parents | 1dac708e7b71 |
children | e7b2424704c1 |
files | enigma/keyfile.py enigma/main.py |
diffstat | 2 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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)