<commit_before>from flask_principal import RoleNeed, Permission
from waitlist.data.names import WTMRoles


class PermissionManager:
    def __init__(self):
        self.permissions = {}
        self.__load_permissions()
    
    def __load_permissions(self):
        self.permissions['admin'] = Permission(RoleNeed(WTMRoles.admin))
        self.__add_permission('dev', Permission(RoleNeed(WTMRoles.dev)))
        self.__add_permission('leadership', Permission(RoleNeed(WTMRoles.leadership)))
        self.__add_permission('officer', Permission(RoleNeed(WTMRoles.officer)))
        self.__add_permission('council', self.get_permission('leadership').union(self.get_permission('officer')))
        self.__add_permission('history_search', self.permissions['leadership'])
        self.__add_permission('inserts', Permission())
        self.__add_permission('trainee', Permission(RoleNeed(WTMRoles.tbadge), RoleNeed(WTMRoles.resident)))
        self.__add_permission('fullcommander', Permission(RoleNeed(WTMRoles.fc), RoleNeed(WTMRoles.lm)))
        self.__add_permission('commandcore', self.permissions['trainee'].union(self.permissions['fullcommander']))
        self.__add_permission('account_notes', self.permissions['officer'].union(self.permissions['leadership']))
        self.__add_permission('view_profile', self.get_permission('council'))
        self.__add_permission('add_notes', self.get_permission('council'))
        self.__add_permission('view_notes', self.get_permission('council').union(self.get_permission('add_notes')))
        self.__add_permission('send_mail', self.get_permission('council'))
        self.__add_permission('calendar_event_see_all', self.get_permission('council'))
        self.__add_permission('fleetview', self.get_permission('dev'))

    def __add_permission(self, name, perm):
        self.permissions[name] = self.permissions['admin'].union(perm)

    def get_permission(self, perm):
        return self.permissions[perm]
    
    def require(self, perm):
        return self.permissions[perm].require()<commit_msg>adjusted permission manager<commit_after>from flask_principal import RoleNeed, Permission


class StaticRoles(object):
    ADMIN = 'admin'


class PermissionManager(object):

    def __init__(self):
        self.__permissions = {}
        self.__definitions = {}
        self.__load_permissions()
    
    def __load_permissions(self):
        pass

    def __add_permission(self, name, perm):
        self.__permissions[name] = self.__permissions['admin'].union(perm)

    def get_permission(self, perm):
        if perm in self.__definitions:
            if perm in self.__permissions:
                return self.__permissions[perm]
            else:
                return Permission(RoleNeed(StaticRoles.ADMIN))
        else:
            raise ValueError(f'Permission [${ perm }] is not defined!')
    
    def require(self, perm):
        return self.__permissions[perm].require()

    def define_permission(self, name):
        self.__definitions[name] = True

    def get_definitions(self):
        return self.__definitions

{'fraction_non_alphanumeric': 0.12155591572123177, 'fraction_numerical': 0.0, 'mean_word_length': 3.9614147909967845, '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': '4716494', 'n_tokens_mistral': 891, 'n_tokens_neox': 848, 'n_words': 132}