<commit_before>import urllib2
from bs4 import BeautifulSoup
import datetime

class newsItem:
    def updateScore(self,score):
        self.score = score
    def __init__(self,text):
        self.text = text
        self.score = 0

def displayAllNews(news):
    for i in range(len(news)):
        print str(i+1) + ". " + news[i].text

def getNews():
    news = []
    try:
        data = urllib2.urlopen("http://www.srmuniv.ac.in").read()
        soup = BeautifulSoup(data,'html.parser')
        for tag in soup.find_all('div',{'class':'views-field views-field-title'}):
            news.append(newsItem(tag.text.strip()))
    except urllib2.URLError:
        return "fail"
    return news

def getNewNews():
    file_name = "oldnews.txt"
    obj = open(file_name)
    oldNews = obj.read().split('\n')
    news = getNews()
    if news == 'fail':
        return "fail"
    newNews = []
    for item in news:
        if item.text not in oldNews:
            newNews.append(item)
    obj.close()
    return newNews

def updateFile(newNews):
    obj = open('oldnews.txt','a')
    for item in newNews:
        obj.write(item.text + '\n')
    obj.close()

def updateLog(msg):
    '''
        -This function will update the status of the bot
         everytime it is executed. All the data goes into
         'logfile.txt'
        -This will help monitor the bot for problems.
    '''
    log = open('logfile.txt','a')<commit_msg>Update srmbot.py<commit_after>import urllib2
from bs4 import BeautifulSoup
import datetime

class newsItem:
    def updateScore(self,score):
        self.score = score
    def __init__(self,text):
        self.text = text
        self.score = 0

def displayAllNews(news):
    for i in range(len(news)):
        print str(i+1) + ". " + news[i].text

def getNews():
    news = []
    try:
        data = urllib2.urlopen("http://www.srmuniv.ac.in").read()
        soup = BeautifulSoup(data,'html.parser')
        for tag in soup.find_all('div',{'class':'views-field views-field-title'}):
            news.append(newsItem(tag.text.strip()))
    except urllib2.URLError:
        return "fail"
    return news

def getNewNews():
    file_name = "old_news.txt"
    obj = open(file_name)
    oldNews = obj.read().split('\n')
    news = getNews()
    if news == 'fail':
        return "fail"
    newNews = []
    for item in news:
        if item.text not in oldNews:
            newNews.append(item)
    obj.close()
    return newNews

def updateFile(newNews):
    obj1 = open('old_news.txt','a')
    abj2 = open('new_news.txt','a')
    for item in newNews:
        obj1.write(item.text + '\n')
        obj2.write(item.text + '\n')
    obj1.close()
    obj2.close()

def updateLog(msg):
    '''
        -This function will update the status of the bot
         everytime it is executed. All the data goes into
         'logfile.txt'
        -This will help monitor the bot for problems.
    '''
    log = open('logfile.txt','a')
{'fraction_non_alphanumeric': 0.13426240652617266, 'fraction_numerical': 0.006118286879673691, 'mean_word_length': 2.3711340206185567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6901654', 'n_tokens_mistral': 968, 'n_tokens_neox': 963, 'n_words': 245}