How to use the boltons.strutils.slugify function in boltons

To help you get started, we’ve selected a few boltons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hatnote / pacetrack / pacetrack / update.py View on Github external
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'
github hatnote / pacetrack / pacetrack / update.py View on Github external
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))
github mahmoud / apatite / apatite / dal.py View on Github external
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)
github mahmoud / chert / chert / hypertext.py View on Github external
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
github mahmoud / chert / chert / hypertext.py View on Github external
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()