diff options
Diffstat (limited to 'overseerlib/parseyaml.py')
-rw-r--r-- | overseerlib/parseyaml.py | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/overseerlib/parseyaml.py b/overseerlib/parseyaml.py index 664f265..8aacfa7 100644 --- a/overseerlib/parseyaml.py +++ b/overseerlib/parseyaml.py @@ -23,21 +23,12 @@ import cliapp class ParseYAML(object): - def parse_yaml(self, self.settings['config-name']): - sender = 'ben.brown@codethink.co.uk' - username = 'benbrown' - password = getpass.getpass() - recipients = ['ben.brown@codethink.co.uk'] - composed_message = '''\ -From: %s -To: %s -Subject: Test - -%s - ''' % (sender, ', '.join(recipients), content) - server = smtplib.SMTP_SSL('imap.codethink.co.uk') - server.login(username, password) + def load_config(self, config): + with open(config) as f: + text = f.read() try: - server.sendmail(sender, recipients, composed_message) - finally: - server.close + obj = yaml.safe_load(text) + except yaml.error.YAMLError as e: + raise cliapp.AppException('Could not load configuration file') + + return obj |