From 3cb5ef05bba0e3bba170453b2691ebf1a1fd3465 Mon Sep 17 00:00:00 2001 From: UmithanGoktolga Date: Thu, 1 Mar 2018 21:02:45 +0300 Subject: [PATCH] Update ExtractMainContent.py In method FileSave, changes made for 'do not saving a file that already exists'. --- News/ExtractMainContent.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/News/ExtractMainContent.py b/News/ExtractMainContent.py index 2677a1e..77c6b4b 100644 --- a/News/ExtractMainContent.py +++ b/News/ExtractMainContent.py @@ -8,6 +8,7 @@ from configReader import ConfigurationReader from Extractor import * import textwrap +import os.path class ExtractMainContent(object): def __init__(self,source,articleurl): @@ -50,6 +51,10 @@ def Beautify(self): def FileSave(self): title,output=self.Extract() + titleName = title+".txt" + if(os.path.isfile(titleName)): + print "File already saved!\n" + return article_file = open(title+".txt","w+") article_file.write(output.encode('utf-8')) article_file.close()