diff --git a/ews_cli/rules.py b/ews_cli/rules.py index 52a9902..ee246f4 100644 --- a/ews_cli/rules.py +++ b/ews_cli/rules.py @@ -1,3 +1,4 @@ +import os.path import yaml from collections import defaultdict from . import util, msg @@ -39,35 +40,38 @@ def load_rules(self): self.filters = [] cfg = util.get_config("filters.yaml") - stream = open(cfg, 'r') - flt = yaml.load(stream) + if os.path.isfile(cfg): - for data in flt: + stream = open(cfg, 'r') - name = data['filter_name'] - folder = data['target_folder'] + flt = yaml.load(stream) - header = data['header'] + for data in flt: - sender = header['sender'] - author = header['from'] - to = header['to'] - reply_to = header['reply_to'] - subject = header['subject'] + name = data['filter_name'] + folder = data['target_folder'] - if data['match'] == 'full': - partial = False - else: - partial = True + header = data['header'] + + sender = header['sender'] + author = header['from'] + to = header['to'] + reply_to = header['reply_to'] + subject = header['subject'] + + if data['match'] == 'full': + partial = False + else: + partial = True - self.add_filter(name,folder,sender,author,to,reply_to,subject,partial) + self.add_filter(name,folder,sender,author,to,reply_to,subject,partial) - try: - from . import rules_custom as rc - rc.load_custom(self) - except ImportError: - print('No Custom Rules Found... skipping...') + try: + from . import rules_custom as rc + rc.load_custom(self) + except ImportError: + print('No Custom Rules Found... skipping...') def save_rules(self): flt = [] diff --git a/setup.py b/setup.py index 533bef1..65d2a16 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,10 @@ from setuptools import setup setup(name='ews-cli', - version='0.1.0.7', + version='0.1.0.8', description='Filter email via EWS endpoint', url='https://github.com/KebinuChiousu/ews_cli', - download_url='https://github.com/KebinuChiousu/ews_cli/archive/v0.1.0.7.tar.gz', + download_url='https://github.com/KebinuChiousu/ews_cli/archive/v0.1.0.8.tar.gz', author='Kevin Meredith', author_email='kevin@meredithkm.info', license='MIT',