本文整理汇总了Python中feedgen.feed.FeedGenerator.updated方法的典型用法代码示例。如果您正苦于以下问题:Python FeedGenerator.updated方法的具体用法?Python FeedGenerator.updated怎么用?Python FeedGenerator.updated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feedgen.feed.FeedGenerator
的用法示例。
在下文中一共展示了FeedGenerator.updated方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import updated [as 别名]
def get_feed(atom=False):
fg = FeedGenerator()
domain = get_domain()
items = get_posts({"limit": "10"}, full=True)["results"]
fg.id("http://%s/"%domain)
fg.title("Blog do MatrUFSC2")
fg.description("Feed do blog do MatrUFSC2, onde noticias e novos recursos sao anunciados primeiro!")
fg.language('pt-BR')
fg.link({"href":"/blog/feed","rel":"self"})
fg.updated(items[0]["posted_at"].replace(tzinfo=pytz.UTC))
for item in items:
entry = fg.add_entry()
entry.title(item["title"])
tree = html.fromstring(item["summary"])
cleaner = Cleaner(allow_tags=[])
tree = cleaner.clean_html(tree)
text = tree.text_content()
entry.description(text, True)
entry.link({"href":item["link"],"rel":"self"})
entry.content(item["body"])
entry.published(item["posted_at"].replace(tzinfo=pytz.UTC))
entry.updated(item["posted_at"].replace(tzinfo=pytz.UTC))
entry.category({"label": item["category"]["title"], "term": item["category"]["slug"]})
entry.id(item["id"])
if atom:
return fg.atom_str(pretty=True)
else:
return fg.rss_str(pretty=True)
示例2: init_fg
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import updated [as 别名]
def init_fg(self, repo_info):
fg = FeedGenerator()
title = 'Recent commits to ' + repo_info['full_name']
fg.title(title)
fg.link(href=repo_info['html_url'])
fg.updated(repo_info['updated_at'])
fg.id(repo_info['html_url'])
fg.author(repo_info['author'])
return fg
示例3: render_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import updated [as 别名]
def render_feed(text_paths, outpath):
# http://rhodesmill.org/brandon/feed
# http://rhodesmill.org/brandon/category/python/feed
# http://rhodesmill.org/brandon/feed/atom/
t0 = datetime.min.time()
def fix(d):
dt = datetime.combine(d, t0)
return timezone('US/Eastern').localize(dt)
posts = [post_info(path) for path in text_paths if date_of(path)]
posts = sorted(posts, key=lambda post: post['date'])
posts = posts[-1:]
most_recent_date = max(post['date'] for post in posts)
def full(url):
return 'http://rhodesmill.org/' + url.lstrip('/')
fg = FeedGenerator()
fg.id(full('/'))
fg.author({'name': 'Brandon Rhodes'})
fg.language('en')
fg.link(href=full('/brandon/'), rel='alternate')
if 'python' in outpath:
fg.link(href=full('/brandon/category/python/feed/'), rel='self')
else:
fg.link(href=full('/brandon/feed/'), rel='self')
fg.subtitle('Thoughts and ideas from Brandon Rhodes')
fg.title("Let's Discuss the Matter Further")
fg.updated(fix(most_recent_date))
for post in posts:
url = full(post['url_path'])
excerpt = truncate_at_more(post['body_html'], url)
fe = fg.add_entry()
fe.content(excerpt, type='html')
fe.guid(url, permalink=True)
fe.id(url)
fe.link({'href': url})
fe.published(fix(post['date']))
fe.title(post['title'])
fe.updated(fix(post['date']))
rss = fg.rss_str(pretty=True)
fg.link(href=full('/brandon/feed/atom/'), rel='self', replace=True)
atom = fg.atom_str(pretty=True)
return rss, atom
示例4: FeedGenerator
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import updated [as 别名]
#
# You should have received a copy of the GNU General Public License
# along with PyCeed. If not, see <http://www.gnu.org/licenses/>.
import feedparser
from feedgen.feed import FeedGenerator
out_feed = FeedGenerator()
url = 'http://www.courantpositif.fr/feed/'
d = feedparser.parse(url)
print("~~ %s ~~" % d.feed.title)
out_feed.title(d.feed.title)
out_feed.subtitle(d.feed.subtitle)
out_feed.id(d.feed.get("id", "no id"))
out_feed.updated(d.feed.updated)
for e in d.entries:
print(" * [%s] %s" % (e.published, e.title))
out_entry = out_feed.add_entry()
out_entry.title(e.title)
out_entry.published(e.published)
out_entry.updated(e.updated)
out_entry.id(e.id)
out_entry.summary(e.summary)
for c in e.content:
out_entry.content(content=c.value, type=c.type) #, src=c.base
for l in e.links:
print(" > [%s] %s" % (l.rel, l.href))
out_entry.link(link=l)
示例5: main
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import updated [as 别名]
def main (args):
"""
main functions
"""
logger = logging.getLogger(sys._getframe().f_code.co_name)
with open(args.config) as f:
config = json.load(f)
logger.debug(pformat(config, indent=4))
# override any loaded config with items specified on command line
for arg, argv in vars(args).iteritems():
if argv is not None:
config[arg] = argv
if 'maximum' not in config.keys():
config['maximum'] = DEFAULTMAXIMUM
logger.debug(pformat(config, indent=4))
# get metadata about the collection
context = '{0}/collections/{1}'.format(config['zotero_account'], config['zotero_collection'])
url = '/'.join((ZOT_BASE, context, '?format=json'))
response = zot_get(url)
alt_html = json.loads(response['content'])['links']['alternate']['href']
# get list of items in collection
context = '{0}/collections/{1}/items/top'.format(config['zotero_account'], config['zotero_collection'])
url = '/'.join((ZOT_BASE, context, '?format=keys&sort=dateModified&direction=desc&limit={0}'.format(config['maximum'])))
logger.debug('fetching: {0}'.format(url))
response = zot_get(url)
if int(response['length']) > 0:
keys = response['content'].split('\n')
else:
print "boom"
if len(keys) > config['maximum']+1:
logger.error("gigantic: {0}".format(len(keys)))
raise Exception
fg = FeedGenerator()
feed_id = u'tag:{domain},{date}:{slug}'.format(
domain=config['tag_domain'],
date=config['tag_date'],
slug=config['tag_slug'])
fg.id(feed_id)
fg.title(config['title'])
fg.author( {'name':config['author_name'],'email':config['author_email']} )
fg.link( href=config['self'], rel='self' )
fg.link( href=alt_html, rel='alternate' )
fg.logo('https://www.zotero.org/support/_media/logo/zotero_256x256x32.png')
fg.language('en')
fg.updated(datetime.now(pytz.utc))
context = '{0}/items'.format(config['zotero_account'])
entries = {}
for key in [k for k in keys if len(k.strip()) > 0]:
logger.info(u'zotero key: "{0}"'.format(key))
url = '/'.join((ZOT_BASE, context, key))
response = zot_get(url)
data = json.loads(response['content'])
zot_link_html = data['links']['alternate']['href']
zot_link_json = data['links']['self']['href']
data = data['data']
logger.info(u'zotero itemType: "{0}"'.format(data['itemType']))
if data['itemType'] == 'note':
logger.warning('ignored note (key="{0}")'.format(key))
elif data['itemType'] == 'attachment':
if data['linkMode'] == u'linked_url':
fe = entries[data['parentItem']]
fe.link(href=data['url'], title=data['title'], rel='alternate')
else:
raise NotImplemented('Zotero attachment (key="{0}") with unhandled linkMode="{1}"'.format(key, data['linkMode']))
else:
fe = fg.add_entry()
entries[key] = fe
entry_id = u'tag:{domain},{date}:{slug}'.format(
domain='zotero.org',
date=data['dateAdded'].split('T')[0],
slug='/'.join((context, key)))
fe.id(entry_id)
try:
fe.title(data['title'])
except KeyError:
logger.warning("unexpected lack of title in zotero record")
logger.debug(pformat(data, indent=2))
raise
try:
creators = data['creators']
except KeyError:
pass
else:
authors = [c for c in data['creators'] if c['creatorType'] == u'author']
for a in authors:
if 'name' in a.keys():
fe.author({'name':a['name']})
else:
fe.author({'name':u'{0} {1}'.format(a['firstName'], a['lastName']), })
try:
fe.link(href=data['url'], rel='alternate', title='link to resource')
except KeyError:
pass
#.........这里部分代码省略.........
示例6: setUp
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import updated [as 别名]
def setUp(self):
fg = FeedGenerator()
self.nsAtom = "http://www.w3.org/2005/Atom"
self.nsRss = "http://purl.org/rss/1.0/modules/content/"
self.feedId = 'http://lernfunk.de/media/654321'
self.title = 'Some Testfeed'
self.authorName = 'John Doe'
self.authorMail = '[email protected]'
self.author = {'name': self.authorName, 'email': self.authorMail}
self.linkHref = 'http://example.com'
self.linkRel = 'alternate'
self.logo = 'http://ex.com/logo.jpg'
self.subtitle = 'This is a cool feed!'
self.link2Href = 'http://larskiesow.de/test.atom'
self.link2Rel = 'self'
self.language = 'en'
self.categoryTerm = 'This category term'
self.categoryScheme = 'This category scheme'
self.categoryLabel = 'This category label'
self.cloudDomain = 'example.com'
self.cloudPort = '4711'
self.cloudPath = '/ws/example'
self.cloudRegisterProcedure = 'registerProcedure'
self.cloudProtocol = 'SOAP 1.1'
self.icon = "http://example.com/icon.png"
self.contributor = {'name': "Contributor Name",
'uri': "Contributor Uri",
'email': 'Contributor email'}
self.copyright = "The copyright notice"
self.docs = 'http://www.rssboard.org/rss-specification'
self.managingEditor = '[email protected]'
self.rating = '(PICS-1.1 "http://www.classify.org/safesurf/" ' + \
'1 r (SS~~000 1))'
self.skipDays = 'Tuesday'
self.skipHours = 23
self.textInputTitle = "Text input title"
self.textInputDescription = "Text input description"
self.textInputName = "Text input name"
self.textInputLink = "Text input link"
self.ttl = 900
self.webMaster = '[email protected]'
fg.id(self.feedId)
fg.title(self.title)
fg.author(self.author)
fg.link(href=self.linkHref, rel=self.linkRel)
fg.logo(self.logo)
fg.subtitle(self.subtitle)
fg.link(href=self.link2Href, rel=self.link2Rel)
fg.language(self.language)
fg.cloud(domain=self.cloudDomain, port=self.cloudPort,
path=self.cloudPath,
registerProcedure=self.cloudRegisterProcedure,
protocol=self.cloudProtocol)
fg.icon(self.icon)
fg.category(term=self.categoryTerm, scheme=self.categoryScheme,
label=self.categoryLabel)
fg.contributor(self.contributor)
fg.copyright(self.copyright)
fg.docs(docs=self.docs)
fg.managingEditor(self.managingEditor)
fg.rating(self.rating)
fg.skipDays(self.skipDays)
fg.skipHours(self.skipHours)
fg.textInput(title=self.textInputTitle,
description=self.textInputDescription,
name=self.textInputName, link=self.textInputLink)
fg.ttl(self.ttl)
fg.webMaster(self.webMaster)
fg.updated('2017-02-05 13:26:58+01:00')
fg.pubDate('2017-02-05 13:26:58+01:00')
fg.generator('python-feedgen', 'x', uri='http://github.com/lkie...')
fg.image(url=self.logo,
title=self.title,
link=self.link2Href,
width='123',
height='123',
description='Example Inage')
self.fg = fg