<commit_before>"""Rights for Pynuts."""

from flask import abort
from functools import wraps


class MetaContext(type):
    """Get context object for rights."""
    def __init__(cls, name, bases, dict_):
        cls._pynuts._context_class = cls


# These classes are decorators, they can begin with an lowercase letter
class acl(object):  # pylint: disable=C0103
    """Utility decorator for access control in ``allow_if`` decorators.

    Allows to write:
    ``@allow_if((Is.admin | Is.in_domain) & ~Is.in_super_domain)``
    given that Is module functions are decorated by acl

    It implements the following operators:

    * ``a & b``: a and b
    * ``a | b``: a or  b
    * ``a ^ b``: a xor b
    * ``~ a``: not a

    """
    def __init__(self, function=lambda context: True):
        self.__name__ = function.__name__
        self.function = function

    def __call__(self):
        """Call the ACL function."""
        return self.function()

    def __or__(self, other):
        """Or operator."""
        def result():
            """Closure for the or operator."""
            return self() or other()<commit_msg>Pass argument to right fun when necessary<commit_after>"""Rights for Pynuts."""

from flask import abort, request
from functools import wraps


class MetaContext(type):
    """Get context object for rights."""
    def __init__(cls, name, bases, dict_):
        cls._pynuts._context_class = cls


# These classes are decorators, they can begin with an lowercase letter
class acl(object):  # pylint: disable=C0103
    """Utility decorator for access control in ``allow_if`` decorators.

    Allows to write:
    ``@allow_if((Is.admin | Is.in_domain) & ~Is.in_super_domain)``
    given that Is module functions are decorated by acl

    It implements the following operators:

    * ``a & b``: a and b
    * ``a | b``: a or  b
    * ``a ^ b``: a xor b
    * ``~ a``: not a

    """
    def __init__(self, function=lambda context: True):
        self.__name__ = function.__name__
        self.function = function

    def __call__(self, **kwargs):
        """Call the ACL function."""
        if self.function.__code__.co_argcount:
            return self.function(kwargs or request.view_args)
        return self.function()

    def __or__(self, other):
        """Or operator."""
        def result():
            """Closure for the or operator."""
            return self() or other()
{'fraction_non_alphanumeric': 0.12282157676348547, 'fraction_numerical': 0.0033195020746887966, 'mean_word_length': 2.7437888198757765, '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': '6018029', 'n_tokens_mistral': 727, 'n_tokens_neox': 700, 'n_words': 251}