<commit_before># coding: utf-8
from language import StoryLanguage
import sys
import re


TEMPLATE_PATTERN = r'\$[a-zA-Z]\w*'
"""
TODO:
    prettify the output of defined steps (patterns), like:
    @When(r'I sum 1 \+ 1'), prettify this kind of pattern
"""

class Step(object):
    '''Step is a baseclass for step directives'''

    name = 'step'

    def __init__(self, message, *args):
        self._message = message
        self._args = args

    def _set_step_attrs(self, local_attrs):
        for private_step in ['_givens', '_whens', '_thens']:
            if not private_step in local_attrs:
                local_attrs[private_step] = []

    def __call__(self, method=None):
        frame = sys._getframe(1)
        step = self.__class__.name
        self._set_step_attrs(frame.f_locals)
        steps = frame.f_locals['_%ss' % step]
        steps.append((method, self._message, self._args))
        return method

class Given(Step):
    name = 'given'

class When(Step):
    name = 'when'

class Then(Step):
    name = 'then'<commit_msg>removed the need of () for defined steps<commit_after># coding: utf-8
from language import StoryLanguage
import sys
import re


TEMPLATE_PATTERN = r'\$[a-zA-Z]\w*'
"""
TODO:
    prettify the output of defined steps (patterns), like:
    @When(r'I sum 1 \+ 1'), prettify this kind of pattern
"""

class Step(object):
    '''Step is a baseclass for step directives'''

    name = 'step'

    def __init__(self, message, *args):
        self._message = message
        self._args = args
        self._context = sys._getframe(1)
        self._set_step_attrs(self._context.f_locals)
        step = self.__class__.name
        self._steps = self._context.f_locals['_%ss' % step]
        self._steps.append((None, self._message, self._args))

    def _set_step_attrs(self, local_attrs):
        for private_step in ['_givens', '_whens', '_thens']:
            if not private_step in local_attrs:
                local_attrs[private_step] = []

    def __call__(self, method=None):
        del self._steps[-1]
        self._steps.append((method, self._message, self._args))
        return method

class Given(Step):
    name = 'given'

class When(Step):
    name = 'when'

class Then(Step):
    name = 'then'
{'fraction_non_alphanumeric': 0.12505562972852693, 'fraction_numerical': 0.004005340453938585, 'mean_word_length': 2.8101694915254236, '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': '3173813', 'n_tokens_mistral': 743, 'n_tokens_neox': 715, 'n_words': 196}