summaryrefslogtreecommitdiff
path: root/parser.py
diff options
context:
space:
mode:
authorsstvinc2 <sstvinc2@gmail.com>2017-02-19 10:56:13 -0600
committersstvinc2 <sstvinc2@gmail.com>2017-02-19 10:56:13 -0600
commit53de97fd3c6fdb4c95a89171b52064a05b157fbf (patch)
treea6bd0a49ee1b11cb0c4b5d9333507411b44071b8 /parser.py
parentd1c7dfc9c2a47edf80527c2457481b9508087ce6 (diff)
Print output formatting
Diffstat (limited to 'parser.py')
-rw-r--r--parser.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/parser.py b/parser.py
index 6b7b0a6..a537d48 100644
--- a/parser.py
+++ b/parser.py
@@ -100,6 +100,16 @@ def removeDuplicates(h1s, h2s, h3s):
+def removalNotification(source, title, reason, value):
+ print('*************************')
+ print('\t\tSTORY REMOVED')
+ print('SOURCE: '+source)
+ print('TITLE: \t'+title)
+ print('REASON: '+reason)
+ print('VALUE: \t'+value)
+ print('*************************\n\n')
+
+
def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr, badURLArr=None):
arr=[source.h1Arr, source.h2Arr, source.h3Arr]
@@ -115,7 +125,7 @@ def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr, b
if i==0:
arr[0].append(arr[1][0])
arr[1].remove(arr[1][0])
- print('Removed:\n'+source.name+'\n'+hed.title+' from '+source.name+'\nReason: Title ('+item+')\n')
+ removalNotification(source.name, hed.title, 'Title', item)
if badDescArr!=None:
@@ -129,7 +139,7 @@ def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr, b
if i==0:
arr[0].append(arr[1][0])
arr[1].remove(arr[1][0])
- print('Removed:\n'+source.name+'\n'+hed.title+' from '+source.name+'\nReason: Description ('+item+')\n')
+ removalNotification(source.name, hed.title, 'Description', item)
if badAuthorArr!=None:
@@ -143,7 +153,7 @@ def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr, b
if i==0:
arr[0].append(arr[1][0])
arr[1].remove(arr[1][0])
- print('Removed:\n'+source.name+'\n'+hed.title+' from '+source.name+'\nReason: Author ('+item+')\n')
+ removalNotification(source.name, hed.title, 'Author', item)
if badImgArr!=None:
@@ -157,7 +167,7 @@ def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr, b
if i==0:
arr[0].append(arr[1][0])
arr[1].remove(arr[1][0])
- print('Removed:\n'+source.name+'\n'+hed.title+' from '+source.name+'\nReason: Image ('+item+')\n')
+ removalNotification(source.name, hed.title, 'Image', item)
if badURLArr!=None:
for i in range(len(arr)):
@@ -170,7 +180,7 @@ def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr, b
if i==0:
arr[0].append(arr[1][0])
arr[1].remove(arr[1][0])
- print('Removed:\n'+source.name+'\n'+hed.title+' from '+source.name+'\nReason: URL ('+item+')\n')
+ removalNotification(source.name, hed.title, 'URL', item)
return source
@@ -328,7 +338,7 @@ def buildBlaze():
blz=buildNewsSource2(name, url, h1s, h2s, h3s)
- blz=removeBadStories(blz, None, None, ['Matt Walsh', 'Tomi Lahren', 'Dana Loesch', 'Mike Opelka'], None)
+ blz=removeBadStories(blz, None, ['Lawrence Jones'], ['Matt Walsh', 'Tomi Lahren', 'Dana Loesch', 'Mike Opelka'], None)
#The Blaze has dumb, short description fields, so we need to grab
#the first x characters of actual article text instead