本文整理匯總了Python中feed.Feed.load方法的典型用法代碼示例。如果您正苦於以下問題:Python Feed.load方法的具體用法?Python Feed.load怎麽用?Python Feed.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類feed.Feed
的用法示例。
在下文中一共展示了Feed.load方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: load
# 需要導入模塊: from feed import Feed [as 別名]
# 或者: from feed.Feed import load [as 別名]
def load(self, store):
for group in store.childGroups():
store.beginGroup(group)
feed = Feed()
feed.load(store)
self.feeds.append(feed)
store.endGroup()
示例2: articles
# 需要導入模塊: from feed import Feed [as 別名]
# 或者: from feed.Feed import load [as 別名]
def articles():
from feed import Feed
# feed = Feed('data/2014-04-05_16-54.atom')
feed = Feed()
feed.load()
return feed.to_json()
示例3: FeedTest
# 需要導入模塊: from feed import Feed [as 別名]
# 或者: from feed.Feed import load [as 別名]
class FeedTest(unittest2.TestCase):
def setUp(self):
import time
self.feed = Feed()
self.savefeed = Feed()
self.savefeed.title = "MyTitle"
self.savefeed.author = "MyAuthor"
self.savefeed.url = "MyUrl"
self.savefeed.homepage = "MyHomepage"
self.savefeed.updated = time.gmtime(time.time())
self.savefeed.deleted_entry_ids = ["123", "456"]
def testLoad(self):
import time
from base64 import b64encode
updated = time.gmtime(time.time())
store = StoreMock()
store.setValue("Title", "TestTitle")
store.setValue("Url", "TestUrl")
store.setValue("Homepage", "Homepage")
store.setValue("Author", "TestAuthor")
store.setValue("Updated", updated)
store.setValue("DeletedEntryIds", ["789","101112"])
store.beginGroup("Entry_%s" % b64encode("Id1"))
store.setValue("Title", "T1")
store.setValue("Updated", updated)
store.setValue("Author", "Author1")
store.setValue("Url", "Url1")
store.setValue("Id", "Id1")
store.setValue("Content", "Content1")
store.setValue("Read", True)
store.endGroup()
store.beginGroup("Entry_%s" % b64encode("Id2"))
store.setValue("Title", "T2")
store.setValue("Updated", updated)
store.setValue("Author", "Author2")
store.setValue("Url", "Url2")
store.setValue("Id", "Id2")
store.setValue("Content", "Content2")
store.endGroup()
self.savefeed.load(store)
self.assertEqual(self.savefeed.title, "TestTitle")
self.assertEqual(self.savefeed.updated, updated)
self.assertEqual(self.savefeed.url, "TestUrl")
self.assertEqual(self.savefeed.homepage, "Homepage")
self.assertEqual(self.savefeed.author, "TestAuthor")
self.assertEqual(self.savefeed.unread, 1)
self.assertEqual(len(self.savefeed.deleted_entry_ids), 2)
self.assertEqual(self.savefeed.deleted_entry_ids, ["789","101112"])
self.assertEqual(len(self.savefeed.entries), 2)
def testSave(self):
entry = Entry()
store = StoreMock()
self.savefeed.entries.append(entry)
self.savefeed.save(store)
self.assertEqual(len(store.childGroups()), 1)
self.assertEqual(self.savefeed.title, store.value("Title"))
self.assertEqual(self.savefeed.author, store.value("Author"))
self.assertEqual(self.savefeed.url, store.value("Url"))
self.assertEqual(self.savefeed.updated, store.value("Updated"))
self.assertEqual(self.savefeed.deleted_entry_ids, store.value("DeletedEntryIds", []))
def testTitle(self):
self.assertIsNone(self.feed.title)
self.feed.title = "test"
self.assertEqual(self.feed.title, "test")
def testAuthor(self):
self.assertIsNone(self.feed.author)
self.feed.author = "test"
self.assertEqual(self.feed.author, "test")
def testHomepage(self):
self.assertIsNone(self.feed.homepage)
self.feed.homepage = "test"
self.assertEqual(self.feed.homepage, "test")
def testFeedUrl(self):
self.assertIsNone(self.feed.url)
self.feed.url = "test"
self.assertEqual(self.feed.url, "test")
def testUpdated(self):
import time
self.assertEqual(self.feed.updated, None)
updated = time.gmtime(time.time())
self.feed.updated = updated
self.assertEqual(self.feed.updated, updated)
def testAdd(self):
self.assertEqual(len(self.feed.entries), 0)
self.feed.entries.append(Entry())
self.assertEqual(len(self.feed.entries), 1)
def testRemove(self):
self.assertEqual(len(self.feed.entries), 0)
self.assertEqual(len(self.feed.deleted_entry_ids), 0)
feed = Entry()
self.feed.entries.append(feed)
#.........這裏部分代碼省略.........