Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render_article_list(self):
all_results = self._get_all_results()
for goal in self.goals:
goal['slug'] = slugify(goal['name'])
ctx = {'name': self.name,
'lang': self.lang,
'description': self.description,
'contacts': self.contacts,
'wikiproject_name': self.wikiproject_name,
'campaign_start_date': self.campaign_start_date.isoformat(),
'campaign_end_date': self.campaign_end_date.isoformat(),
'date_created': self.date_created.isoformat(),
'date_updated': datetime.datetime.utcnow().strftime(UPDATED_DT_FORMAT),
'article_count': len(self.article_title_list),
'all_results': all_results,
'goals': [{'name': 'Article', 'slug': 'title'}] + sorted(self.goals, key=lambda s: s['name'])}
campaign_static_path = STATIC_PATH + 'campaigns/%s/' % self.id
article_list_html = ASHES_ENV.render('articles.html', ctx)
article_list_path = campaign_static_path + 'articles.html'
article_list_json_path = campaign_static_path + 'articles.json'
key=lambda p: slugify(p.name),
groups=True)
def validate_campaign_id(_, __, id_text):
if slugify(id_text) == id_text:
return
raise ValueError('expected campaign id to consist of lowercase printable characters,'
' with no punctuation except for underscores, like "%s", not %r'
% (slugify(id_text), id_text))
def get_project(self, name):
name_slug = slugify(name)
for proj in self.project_list:
if proj.name_slug == name_slug:
return proj
raise LookupError('no such project: %r' % name)
def __init__(self, html_tree, marker, title, base_header_level=1,
make_anchor_id=slugify):
self.html_tree = html_tree
self.marker = marker
self.title = title
self.base_header_level = base_header_level
self.make_anchor_id = make_anchor_id
def add_toc(html_tree, marker='[TOC]', title='Contents',
base_header_level=1, make_anchor_id=slugify):
"""Adds a table of contents div where *marker* can be found within p
tags on its own. Turns headings into links and optionally adjusts
their level to be suitable for inclusion in a larger document.
Input can be text or utf-8 bytes, but the return is text (aka a
unicode object).
Intended to be used on the "content" (part below the post title)
of the HTML layout of an entry.
"""
tocifier = TOCifier(html_tree=html_tree,
marker=marker,
title=title,
base_header_level=base_header_level,
make_anchor_id=make_anchor_id)
tocifier.process()