<commit_before># -*- coding: utf-8 -*-

import arrow

from jinja2 import nodes
from jinja2.ext import Extension


class TimeExtension(Extension):
    tags = set(['now'])

    def __init__(self, environment):
        super(TimeExtension, self).__init__(environment)

        # add the defaults to the environment
        environment.extend(
            date_format='%Y-%m-%d',
        )

    def _now(self, timezone, date_format):
        date_format = date_format or self.environment.date_format
        return arrow.now(timezone).strftime(date_format)

    def parse(self, parser):
        lineno = next(parser.stream).lineno

        args = [parser.parse_expression()]

        if parser.stream.skip_if('comma'):
            args.append(parser.parse_expression())
        else:
            args.append(nodes.Const(None))

        call = self.call_method('_now', args, lineno=lineno)

        return nodes.Output([call], lineno=lineno)<commit_msg>Change environment attribute name to datetime_format<commit_after># -*- coding: utf-8 -*-

import arrow

from jinja2 import nodes
from jinja2.ext import Extension


class TimeExtension(Extension):
    tags = set(['now'])

    def __init__(self, environment):
        super(TimeExtension, self).__init__(environment)

        # add the defaults to the environment
        environment.extend(
            datetime_format='%Y-%m-%d',
        )

    def _now(self, timezone, datetime_format):
        datetime_format = datetime_format or self.environment.datetime_format
        return arrow.now(timezone).strftime(datetime_format)

    def parse(self, parser):
        lineno = next(parser.stream).lineno

        args = [parser.parse_expression()]

        if parser.stream.skip_if('comma'):
            args.append(parser.parse_expression())
        else:
            args.append(nodes.Const(None))

        call = self.call_method('_now', args, lineno=lineno)

        return nodes.Output([call], lineno=lineno)
{'fraction_non_alphanumeric': 0.11332312404287902, 'fraction_numerical': 0.0030627871362940277, 'mean_word_length': 2.843137254901961, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2820421', 'n_tokens_mistral': 574, 'n_tokens_neox': 544, 'n_words': 122}