<commit_before>"""Method decorators for Schevo.

For copyright, license, and warranty, see bottom of file.
"""

import sys
from schevo.lib import optimize


class _labelable_classmethod(object):

    _label = None
    _marker = None

    def __init__(self, fn):
        self.fn = fn
        setattr(fn, self.marker, True)
        self._label = getattr(fn, '_label', None)

    def first_arg(self, instance, owner):
        return None

    def __get__(self, instance, owner):
        return self.labelable_callable(
            self, owner, self.first_arg(instance, owner))

    class labelable_callable(object):

        def __init__(self, decorator, owner, firstarg):
            self.decorator = decorator
            self.owner = owner
            self.firstarg = firstarg

        def __call__(self, *args, **kw):
            return self.decorator.fn(self.firstarg, *args, **kw)

        def __repr__(self):
            return '<%s method %s.%s at 0x%x>' % (
                self.owner.__name__,
                self.decorator.fn.__name__,
                id(self),
                )

        # _label

        def _get_label(self):
            return self.decorator._label

        def _set_label(self, value):<commit_msg>Correct __repr__ of the callable returned by the descriptor decorators in schevo.decorator<commit_after>"""Method decorators for Schevo.

For copyright, license, and warranty, see bottom of file.
"""

import sys
from schevo.lib import optimize


class _labelable_classmethod(object):

    _label = None
    _marker = None

    def __init__(self, fn):
        self.fn = fn
        setattr(fn, self.marker, True)
        self._label = getattr(fn, '_label', None)

    def first_arg(self, instance, owner):
        return None

    def __get__(self, instance, owner):
        return self.labelable_callable(
            self, owner, self.first_arg(instance, owner))

    class labelable_callable(object):

        def __init__(self, decorator, owner, firstarg):
            self.decorator = decorator
            self.owner = owner
            self.firstarg = firstarg

        def __call__(self, *args, **kw):
            return self.decorator.fn(self.firstarg, *args, **kw)

        def __repr__(self):
            return '<%s %s at 0x%x>' % (
                self.decorator.__class__.__name__,
                self.decorator.fn.__name__,
                id(self),
                )

        # _label

        def _get_label(self):
            return self.decorator._label

        def _set_label(self, value):
{'fraction_non_alphanumeric': 0.09932991722506898, 'fraction_numerical': 0.0007883326763894363, 'mean_word_length': 2.117936117936118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7206389', 'n_tokens_mistral': 760, 'n_tokens_neox': 721, 'n_words': 195}