feed knows how to print information about itself
This commit is contained in:
parent
d1520b3827
commit
8da6ef9010
13
atomstrom.py
13
atomstrom.py
@ -220,18 +220,9 @@ def list_all_feeds(session):
|
||||
totalfeeds = 0
|
||||
totalentries = 0
|
||||
for feed in allfeeds:
|
||||
id = feed.id
|
||||
if feed.feedinfo:
|
||||
title = feed.feedinfo.title
|
||||
last = feed.feedinfo.lastsuccessful
|
||||
else:
|
||||
title = '<unknown>'
|
||||
last = '<never>'
|
||||
entries = len(feed.entry)
|
||||
url = feed.url
|
||||
print '%3d %s (%d entries, last fetched %s)\n %s' % (id, title, entries, last, url)
|
||||
print unicode(feed)
|
||||
totalfeeds += 1
|
||||
totalentries += entries
|
||||
totalentries += len(feed.entry)
|
||||
print 'TOTAL: %d entries in %d feeds.' % (totalentries, totalfeeds)
|
||||
|
||||
def fetch_all_feeds(session):
|
||||
|
@ -28,5 +28,20 @@ class Feed(Base):
|
||||
self.html2textcontent = html2textcontent
|
||||
self.enabled = enabled
|
||||
|
||||
def __unicode__(self):
|
||||
id = self.id
|
||||
if self.feedinfo:
|
||||
title = self.feedinfo.title
|
||||
last = self.feedinfo.lastsuccessful
|
||||
else:
|
||||
title = '<unknown>'
|
||||
last = '<never>'
|
||||
entries = len(self.entry)
|
||||
url = self.url
|
||||
return u'%3d %s (%d entries, last fetched %s)\n %s' % (id, title, entries, last, url)
|
||||
|
||||
def __str__(self):
|
||||
return unicode(self).encode('utf-8')
|
||||
|
||||
def __repr__(self):
|
||||
return "<Feed('%s','%s','%s')>" % (self.url, self.daily, self.readability)
|
||||
return "<Feed('%d','%s')>" % (self.id, self.url)
|
||||
|
Loading…
Reference in New Issue
Block a user