<commit_before>import feedparser
import time

RSS_LINK = 'http://euw.leagueoflegends.com/en/rss.xml'
DATA_FILE = 'RSSData'


def main():

    feed = feedparser.parse(RSS_LINK)

    # latestItemDate = feed.entries[0].published_parsed

    # for story in feed.entries:
    #     print(story.published_parsed)
    #     print('\n')
    print(feed.entries[0].published)
    latestItemDate = getDateOfLatestRead()

    getNewItems(latestItemDate)

    input()

def getDateOfLatestRead():
    dateOfLatestRead = None

    try:
        dataFile  = open(DATA_FILE,'r')
        dateOfLatestRead = dataFile.readline()
        dataFile.close()
    except FileNotFoundError:
        print("file not found, making file")
        dateOfLatestRead = '2000 01 01 00 00 00'
        dataFile  = open(DATA_FILE,'w+')
        dataFile.write(dateOfLatestRead)
        dataFile.close()


    # dateOfLatestRead =  dateOfLatestRead.split(',')

    dateOfLatestRead  = time.strptime(dateOfLatestRead, "%Y %m %d %H %M %S %Z") 

    return dateOfLatestRead

def setDateOfLatestRead(dateToSet):
    dataFile  = open(DATA_FILE,'w+')
    dataFile.write('')
    dataFile.close()


def getNewItems(latestDateRead):
  

    feed = feedparser.parse(RSS_LINK)

    print(latestDateRead)


# def setRSSFeedLink():

# def printToConsole():

if __name__ == "__main__":
    main()


<commit_msg>RSSReader can now get items after a certain date<commit_after>import feedparser
import time

RSS_LINK = 'http://euw.leagueoflegends.com/en/rss.xml'
DATA_FILE = 'RSSData.txt'


def main():

    feed = feedparser.parse(RSS_LINK)

    # latestItemDate = feed.entries[0].published_parsed

   

    
    latestDateRead = getDateOfLatestRead()

    newItems = getNewItems(latestDateRead)
    if newItems != None:
        for item in newItems:
            print(item.title.encode('utf8'))
            print('\n')

    input()

def getDateOfLatestRead():
    dateOfLatestRead = None

    try:
        dataFile  = open(DATA_FILE,'r')
        dateOfLatestRead = dataFile.readline()
        dataFile.close()
    except FileNotFoundError:
        print("file not found, making file")
        dateOfLatestRead = 'Sat, 05 Aug 2017 19:34:59 +0000' #date this file was created
        dataFile  = open(DATA_FILE,'w+')
        dataFile.write(dateOfLatestRead)
        dataFile.close()

    dateOfLatestRead  = time.strptime(dateOfLatestRead, "%a, %d %b %Y %H:%M:%S %z") 

    return dateOfLatestRead


def setDateOfLatestRead(dateToSet):
    dataFile  = open(DATA_FILE,'w+')
    dataFile.write(dateToSet)
    dataFile.close()


def getNewItems(latestDateRead):
  

    feed = feedparser.parse(RSS_LINK)
    newLatestDateReadParsed = feed.entries[0].published_parsed
    newLatestDateRead =  feed.entries[0].published

    newItems= []

    for item in feed.entries:
        #manual parsing because saved date has been manually parsed and has a -1
        #the is_dst value casuing the comparisons to be incorrect.
        item.parsedDate  = time.strptime(item.published, "%a, %d %b %Y %H:%M:%S %z") 
        if latestDateRead < item.parsedDate:
            newItems.insert(0,item)
        if  item.parsedDate> newLatestDateReadParsed:
            newLatestDateRead = item.published
            newLatestDateReadParsed = item.parsedDate


    setDateOfLatestRead(newLatestDateRead)
    return newItems

# def setRSSFeedLink():

# def printToConsole():

if __name__ == "__main__":
    main()



{'fraction_non_alphanumeric': 0.10839160839160839, 'fraction_numerical': 0.011072261072261072, 'mean_word_length': 3.0723606168446027, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3040780', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1135, 'n_words': 235}