Пример #1
0
    def __getFeeds(self, file):
        """
        `Author`: Eliakah kakou

        This method generates a Feed instance from the file given

        `file`: full file path

        `return`: Feed generated from file
        """
        title = self.__getFileName(file)
        input_file = open(file)
        try:
            content = input_file.read()
        finally:
            input_file.close()

        stamp = time.ctime(self.__creation_date(file))

        f = {
            'id': file,
            'published': stamp,
            'title': title,
            'link': file,
            'summary': content
        }
        f = Feed(f)
        return f
Пример #2
0
 def dict_to_feed(self, feed_dict):
     feed = Feed(feed_id=feed_dict["feed_id"],
                 title=feed_dict["title"],
                 description=feed_dict["description"],
                 link=feed_dict["link"],
                 date_updated=feed_dict["date_updated"],
                 feed_copyright=feed_dict["feed_copyright"])
     return feed
Пример #3
0
 def convert(self):
     for feed in self.feeds_index_dict:
         converted_feed = Feed(
             feed_id=feed["feed_id"],
             title=feed["title"],
             description=feed["description"],
             link=feed["link"],
             date_updated=feed["date_updated"],
             feed_copyright=feed["feed_copyright"]
         )
         self.items.append(converted_feed)
Пример #4
0
    def loading_feeds(self):
        feed = Feed(self.engine)

        print("Check for new feeds: ", end="", flush=True)
        feed.load_new_feeds_from_file("sites")
        print("Done")

        print("Loading feeds: ")
        feed.load_new_articles()

        print("Loading articles: ")
        # Article(self.engine).check_articles_limited()
        feed.check_articles_limited()
Пример #5
0
def main():

    # set a name to a feed
    yasmin = Feed.Feed("yasmin")
    esther = Feed.Feed("esther")
    vera = Feed.Feed("vera")

    # Feed erstellen
    yasmin.generateOwnFeed()
    esther.generateOwnFeed()
    vera.generateOwnFeed()

    # set person
    yasminPerson = Person.Person(yasmin.id, yasmin.name, yasmin)
    yasminPerson.follow(esther.id, esther.name)
    yasminPerson.follow(vera.id, vera.name)
    yasminPerson.printFollowList()
    yasminPerson.unfollow(vera.id)
    yasminPerson.printFollowList()

    veraPerson = Person.Person(vera.id, vera.name, vera)
    veraPerson.follow(esther.id, esther.name)
    veraPerson.follow(yasmin.id, yasmin.name)
    veraPerson.printFollowList()
Пример #6
0
def getBestFeed(feedList):
    maxScore = 0.0
    maxFeed = Feed("", -1, -2, -3)
    tmpDict = {}
    for feed in feedList:
        if (tmpDict.get(feed.getScore(), 0) == 1):
            continue
        else:
            tmpDict[feed.getScore()] = 1
        sumScore = 0.0
        for tmp in feedList:
            tmpScore = feed.calculateDelta(tmp)
            sumScore = sumScore + tmpScore
        if sumScore > maxScore:
            maxScore = sumScore
            maxFeed = feed
    return maxFeed
Пример #7
0
    def __getFeeds(self, url):
        """
        `Author`: Eliakah kakou

        This method generates a Feed instance from the url given

        `file`: full file path

        `return`: Feed generated from file
        """
        flag = validators.url(url)
        if flag:
            feeds = feedparser.parse(url)
        else:
            sys.exit("Invalid Url: Please try again!")

        list = feeds['entries']
        for i in range(len(list)):
            list[i] = Feed(list[i])
            feeds = list

        return feeds
Пример #8
0
    # 读入数据
    while 1:
        line = file.readline()
        if not line:
            break

        arr = line.split("\t")
        if (len(arr) < 6):
            continue
        uid = arr[0]
        repost_count = int(arr[3])
        comment_count = int(arr[4])
        like_count = int(arr[5])

        feed = Feed(uid, int(repost_count), int(comment_count),
                    int(like_count))
        feedList = feed_dict.get(uid, [])
        if (feedList == []):
            feedList.append(feed)
        else:
            feedList.append(feed)
        feed_dict[uid] = feedList

        pass

    print("read over")
    count = 0
    for uid in feed_dict.keys():
        feedList = feed_dict.get(uid, "0,0,0")
        result_dict[uid] = getBestFeed(feedList).getScore()
        count = count + 1
Пример #9
0
 def GET(self):
   web.header('Content-Type', 'application/json')
   feed = Feed(mysql)
   return json.dumps(feed.list(3))
Пример #10
0
from Feed import Feed

if __name__ == "__main__":
    print("hello")
    feed1 = Feed("1", int("3"), int("4"), int("5"))
    feed2 = Feed("2", int("3"), int("6"), int("7"))
    a = []
    print(a == [])
    a.append(feed1)
    print(a)
    feed1.printFeed()
    print(feed1.calculateDelta(feed2))
    print(feed1.getScore())
Пример #11
0
 def get_feed(self):
     return Feed(self.data_miner_with_cache(['feed', self.student_id]))
Пример #12
0
 def getFeed(self,feedId = config.ALLDATA_FEEDID):
     from Feed import Feed
     return Feed({"feedId": feedId, "filter": {"byCategories": self.name}})
Пример #13
0
import MySQLdb
import MySQLdb.cursors
import json
from Feed import Feed

db = MySQLdb.connect(host="localhost",
                     user="******",
                     passwd="",
                     db="emoncms",
                     cursorclass=MySQLdb.cursors.DictCursor)
cursor = db.cursor()

feed = Feed(cursor)
print json.dumps(feed.list(3))