Skip to content

Commit

Permalink
Fix bug when filters.yaml is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Meredith committed Aug 24, 2018
1 parent 3d27aae commit a073802
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
46 changes: 25 additions & 21 deletions ews_cli/rules.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os.path
import yaml
from collections import defaultdict
from . import util, msg
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit a073802

Please sign in to comment.