<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask.ext.principal import Permission

class RoleElt(tuple):

    def doc(self, doc):
        self.__doc__ = doc
        self.all[self] = self

    def __getattr__(self, attr):
        new = RoleElt(self + (attr,))
        new.all = self.all
        setattr(self, attr, new)
        return new

    def require(self):
        if self not in self.all:
            raise RuntimeError("Cannot require undocumented permission %r" % '.'.join(self))
        return Permission(self).require()


class RootRoleElt(RoleElt):

    def __init__(self):
        self.all = {}

    def __getitem__(self, index):
        if not isinstance(index, tuple):
            index = tuple(index.split('.'))
        return self.all[index]


roles = RootRoleElt()<commit_msg>add a 'get' method<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask.ext.principal import Permission

class RoleElt(tuple):

    def doc(self, doc):
        self.__doc__ = doc
        self.all[self] = self

    def __getattr__(self, attr):
        new = RoleElt(self + (attr,))
        new.all = self.all
        setattr(self, attr, new)
        return new

    def require(self):
        if self not in self.all:
            raise RuntimeError("Cannot require undocumented permission %r" % '.'.join(self))
        return Permission(self).require()


class RootRoleElt(RoleElt):

    def __init__(self):
        self.all = {}

    def __getitem__(self, index):
        if not isinstance(index, tuple):
            index = tuple(index.split('.'))
        return self.all[index]

    def get(self, index, default=None):
        try:
            return self[index]
        except KeyError:
            return default


roles = RootRoleElt()
{'fraction_non_alphanumeric': 0.10961538461538461, 'fraction_numerical': 0.0038461538461538464, 'mean_word_length': 2.4226973684210527, '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': '212231', 'n_tokens_mistral': 647, 'n_tokens_neox': 613, 'n_words': 203}