<commit_before># -*- encoding: utf-8 -*-
# ! python2

"""
Template tags.
"""

from __future__ import unicode_literals
from __future__ import print_function
from __future__ import absolute_import

from django.template import Library
from django.contrib.staticfiles import finders

from django_cbtp_email.errors import CssForEmailNotFoundError

register = Library()


@register.simple_tag()
def css_direct(css_path):
    """
    :type css_path: str
    """
    if not css_path.endswith(".css"):
        raise ValueError("c")

    result = finders.find(css_path)

    if not result:
        raise CssForEmailNotFoundError(
            "Cannot find \"{}\", searched locations: {}".format(css_path, finders.searched_locations))

    with open(result) as the_file:
        css_content = the_file.read()

    return "<style type=\"text/css\">{0}</style>".format(css_content)<commit_msg>+ Template tag for file:/// include.<commit_after># -*- encoding: utf-8 -*-
# ! python2

"""
Template tags.
"""

from __future__ import unicode_literals
from __future__ import print_function
from __future__ import absolute_import

from django.template import Library
from django.contrib.staticfiles import finders
from django.templatetags.static import static

from django_cbtp_email.errors import CssForEmailNotFoundError

register = Library()


@register.simple_tag()
def css_direct(css_path):
    """
    :type css_path: str
    """
    if not css_path.endswith(".css"):
        raise ValueError("c")

    result = finders.find(css_path)

    if not result:
        raise CssForEmailNotFoundError(
            "Cannot find \"{}\", searched locations: {}".format(css_path, finders.searched_locations))

    with open(result) as the_file:
        css_content = the_file.read()

    return "<style type=\"text/css\">{0}</style>".format(css_content)


@register.simple_tag(takes_context=True)
def static_direct(context, static_path):
    """
    :type static_path: str
    """
    if "request" in context:
        return static(static_path)

    return "file:///{}".format(finders.find(static_path))
{'fraction_non_alphanumeric': 0.1203659123736158, 'fraction_numerical': 0.002888781896966779, 'mean_word_length': 3.8551401869158877, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5891894', 'n_tokens_mistral': 642, 'n_tokens_neox': 628, 'n_words': 155}