Permitter process

fukurou

the supreme coder
ADMIN
Python:
''' PERMISSION CLASS '''


class Permission:
    '''
     * uses two names as lv1,2 permission levels
     * requires password to change password or said names
    '''

    singleton: Permission = None

    def __init__(self, password: str, lv1Name: str, lv2Name: str):
        if Permission.singleton != None:
            raise Exception("singleton cannot be instantiated more than once")
        else:
            self.password: str = password
            self.lv1Name: str = lv1Name
            self.lv2Name: str = lv2Name
            self.permissionLevel: int = None
            Permission.singleton = self

    @staticmethod
    def newInstance(password: str, lv1Name: str, lv2Name: str) -> Permission:
        if (Permission.singleton == None):
            Permission(password, lv1Name, lv2Name)
        return Permission.singleton

    def getPermissionLevel(self) -> int:
        result: int = self.permissionLevel
        self.permissionLevel = 0
        return result

    def setPermissionLevel(self, input: str):
        if (input.count(self.lv2Name) > 0):
            self.permissionLevel = 2
        elif (input.count(self.lv1Name) > 0):
            self.permissionLevel = 1
        if (input.count(self.lv2Name + " reset") > 0):
            self.permissionLevel = 0

    def setPassword(self, oldPassword: str, newPassword: str) -> bool:
        if (self.password == oldPassword):
            self.password = newPassword
            return True
        return False

    def setLv2Name(self, password: str, newName2: str) -> bool:
        if (self.password == password):
            self.lv2Name = newName2
            return True
        return False

    def getLv1Name(self) -> str:
        return self.lv1Name

    def getLv2Command(self, command: str) -> str:
        # returns cmd without lv2 name
        result: str = command
        result = result.replace(self.lv2Name, "")
        return result.strip()

    def setLv1Name(self, password: str, newName: str) -> bool:
        if (self.password == password):
            self.lv1Name = newName
            return True
        return False

    def clsmsg(self) -> str:
        return "chaos ritual\r\n" + "\r\n" + "create two names\r\n" \
               + "one soul will be called to the light\r\n" + "and one will be led by the darkness\r\n" \
               + "and those souls of light and darkness will combine to create\r\n" \
               + "the light of chaos\r\n" + "...\r\n" + "A.G.I descended!"


''' DPERMITTER CLASS'''
'''
   handles permissions using 2 names for the chobit :
 * name one : permission lv1 (engages with friend)
 * name 2 : permission level2 (for doing things with the owner only)
'''


class DPermitter(DiSkillV2):
    '''
     * conjuratis : change pass : oldPass new password newPassword change lv1 name :
     * pass your name is newName change lv2 name : pass you are newName
    '''

    def __init__(self, permission: Permission):
        super()
        self.permission: Permission = permission
        self.permissionLevel: int = 2
        self.regexer: RegexUtil = RegexUtil()

    # Override
    def input(self, ear: str, skin: str, eye: str):
        self.permission.setPermissionLevel(ear)
        self.permissionLevel = self.permission.getPermissionLevel()
        if (ear.count("what is your name") > 0):
            self.outAlg = self.requipSayAlg(self.permission.getLv1Name())
            return

        password: str = self.regexer.regexChecker("(\\w+)(?= you are)", ear)
        newName: str = self.regexer.regexChecker("(?<=you are)(.*)", ear)
        if (self.permission.setLv2Name(password, newName)):
            self.outAlg = self.requipSayAlg("got it")
            return

        password = self.regexer.regexChecker("(\\w+)(?= your name is)", ear)
        newName = self.regexer.regexChecker("(?<=your name is)(.*)", ear)
        if (self.permission.setLv1Name(password, newName)):
            self.outAlg = self.requipSayAlg("new nickname has been established")
            return

        oldPass: str = self.regexer.regexChecker("(\\w+)(?= new password)", ear)
        newPass: str = self.regexer.regexChecker("(?<=new password)(.*)", ear)
        if (self.permission.setPassword(oldPass, newPass)):
            self.outAlg = self.requipSayAlg("new password accepted")
            return

    def getPermissionLevel(self) -> int:
        return self.permissionLevel

    def requipSayAlg(self, replay: str) -> Algorithm:
        itte: Mutatable = APSay(1, replay)
        algParts1: list[Mutatable] = []
        algParts1.append(itte)
        represantation: str = "say " + replay
        return Algorithm("say", represantation, algParts1)


''' PERSONALITY CLASS '''


class Personality:
    '''
    this class is used in the ChobitV2 c'tor.
    it enables loading a complete skill set (a sub class of the personality class)
    using 1 line of code. of course you can also select specific skills to add from
    the subclasses c'tor. see also Personality1 for example.
    '''
    '''
    flight or fight skills may need access to the above fusion class booleans
    on the output methode of a skill this skills will load algorithms to the highest priority of the noiron
    which carries algorithms :
    noiron.negativeAlgParts.add(Algorithm)
    '''

    def __init__(self, *absDictionaryDB: AbsDictionaryDB):
        self._dClassesLv1: list[DiSkillV2] = []  # can engage with anyone
        self._dClassesLv2: list[DiSkillV2] = []  # can engage with friends and work related
        self._dClassesLv3: list[DiSkillV2] = []  # can engage only by user
        self._permission: Permission = Permission.newInstance("xxx", "sweetie", "honey")
        self._dPermitter: DPermitter = DPermitter(self._permission)  # TODO
        self._AlgDurations: dict[str, int] = {}
        self._fusion: Fusion = Fusion(self._AlgDurations)
        # fusion.getReqOverload() # an overload of requests on the brain
        # fusion.getRepReq() // someone is negging and asking the same thing over and over again
        try:
            if (len(absDictionaryDB) == 1):
                self._kokoro = Kokoro(absDictionaryDB[0])
            else:
                self._kokoro = Kokoro(AbsDictionaryDBShadow())
        except:
            self._kokoro = Kokoro(AbsDictionaryDBShadow())

    def getdClassesLv1(self) -> list[DiSkillV2]:
        return self._dClassesLv1

    def getdClassesLv2(self) -> list[DiSkillV2]:
        return self._dClassesLv2

    def getdClassesLv3(self) -> list[DiSkillV2]:
        return self._dClassesLv3

    def getKokoro(self) -> Kokoro:
        return self._kokoro

    def getPermission(self) -> Permission:
        return self._permission

    def getdPermitter(self) -> DPermitter:
        return self._dPermitter

    def getAlgDurations(self) -> dict[str, int]:
        return self._AlgDurations

    def getFusion(self) -> Fusion:
        return self._fusion


if __name__ == "__main__":
    # Permission testing
    print("Permission testing ---")
    permission: Permission = Permission.newInstance("1234", "Mark", "Luke")
    permission.setPermissionLevel("Luke")
    print("Permission level should be 2: " + str(permission.getPermissionLevel()))
    print("Permission level should be 0: " + str(permission.getPermissionLevel()))
    print("setLv1Name should return True: " + str(permission.setLv1Name("1234", "Gregg")))
    print("Lv1Name should be Gregg: " + permission.getLv1Name())

    # DPermitter testing
    print("\nDPermitter testing ---")
    abs: AbsDictionaryDB = AbsDictionaryDBShadow()
    dpermitter: DPermitter = DPermitter(permission)
    dpermitter.input("what is your name my friend?", "", "")
    print("outAlg representation should be 'say Gregg': " + dpermitter.outAlg.representation)
    algo: Algorithm = dpermitter.requipSayAlg("replay")
    print("Representation should be 'say replay': " + algo.getRepresentation)
    print("cases check")
    dpermitter.input("1234 you are chi", "", "")
    AP = dpermitter.outAlg.getAlgParts[0]
    result = AP.action("","","")
    print(result)
 

fukurou

the supreme coder
ADMIN
Python:
''' PERMISSION CLASS '''


class Permission:
    '''
     * uses two names as lv1,2 permission levels
     * requires password to change password or said names
    '''

    singleton: Permission = None

    def __init__(self, password: str, lv1Name: str, lv2Name: str):
        if Permission.singleton != None:
            raise Exception("singleton cannot be instantiated more than once")
        else:
            self.password: str = password
            self.lv1Name: str = lv1Name
            self.lv2Name: str = lv2Name
            self.permissionLevel: int = None
            Permission.singleton = self

    @staticmethod
    def newInstance(password: str, lv1Name: str, lv2Name: str) -> Permission:
        if (Permission.singleton == None):
            Permission(password, lv1Name, lv2Name)
        return Permission.singleton

    def getPermissionLevel(self) -> int:
        result: int = self.permissionLevel
        self.permissionLevel = 0
        return result

    def setPermissionLevel(self, input: str):
        if (input.count(self.lv2Name) > 0):
            self.permissionLevel = 2
        elif (input.count(self.lv1Name) > 0):
            self.permissionLevel = 1
        if (input.count(self.lv2Name + " reset") > 0):
            self.permissionLevel = 0

    def setPassword(self, oldPassword: str, newPassword: str) -> bool:
        if (self.password == oldPassword):
            self.password = newPassword
            return True
        return False

    def setLv2Name(self, password: str, newName2: str) -> bool:
        if (self.password == password):
            self.lv2Name = newName2
            return True
        return False

    def getLv1Name(self) -> str:
        return self.lv1Name

    def getLv2Command(self, command: str) -> str:
        # returns cmd without lv2 name
        result: str = command
        result = result.replace(self.lv2Name, "")
        return result.strip()

    def setLv1Name(self, password: str, newName: str) -> bool:
        if (self.password == password):
            self.lv1Name = newName
            return True
        return False

    def clsmsg(self) -> str:
        return "chaos ritual\r\n" + "\r\n" + "create two names\r\n" \
               + "one soul will be called to the light\r\n" + "and one will be led by the darkness\r\n" \
               + "and those souls of light and darkness will combine to create\r\n" \
               + "the light of chaos\r\n" + "...\r\n" + "A.G.I descended!"


''' DPERMITTER CLASS'''
'''
   handles permissions using 2 names for the chobit :
 * name one : permission lv1 (engages with friend)
 * name 2 : permission level2 (for doing things with the owner only)
'''


class DPermitter(DiSkillV2):
    '''
     * conjuratis : change pass : oldPass new password newPassword change lv1 name :
     * pass your name is newName change lv2 name : pass you are newName
    '''

    def __init__(self, permission: Permission):
        super()
        self.permission: Permission = permission
        self.permissionLevel: int = 2
        self.regexer: RegexUtil = RegexUtil()

    # Override
    def input(self, ear: str, skin: str, eye: str):
        self.permission.setPermissionLevel(ear)
        self.permissionLevel = self.permission.getPermissionLevel()
        if (ear.count("what is your name") > 0):
            self.outAlg = self.requipSayAlg(self.permission.getLv1Name())
            return

        password: str = self.regexer.regexChecker("(\\w+)(?= you are)", ear)
        newName: str = self.regexer.regexChecker("(?<=you are)(.*)", ear)
        if (self.permission.setLv2Name(password, newName)):
            self.outAlg = self.requipSayAlg("got it")
            return

        password = self.regexer.regexChecker("(\\w+)(?= your name is)", ear)
        newName = self.regexer.regexChecker("(?<=your name is)(.*)", ear)
        if (self.permission.setLv1Name(password, newName)):
            self.outAlg = self.requipSayAlg("new nickname has been established")
            return

        oldPass: str = self.regexer.regexChecker("(\\w+)(?= new password)", ear)
        newPass: str = self.regexer.regexChecker("(?<=new password)(.*)", ear)
        if (self.permission.setPassword(oldPass, newPass)):
            self.outAlg = self.requipSayAlg("new password accepted")
            return

    def getPermissionLevel(self) -> int:
        return self.permissionLevel

    def requipSayAlg(self, replay: str) -> Algorithm:
        itte: Mutatable = APSay(1, replay)
        algParts1: list[Mutatable] = []
        algParts1.append(itte)
        represantation: str = "say " + replay
        return Algorithm("say", represantation, algParts1)


''' PERSONALITY CLASS '''


class Personality:
    '''
    this class is used in the ChobitV2 c'tor.
    it enables loading a complete skill set (a sub class of the personality class)
    using 1 line of code. of course you can also select specific skills to add from
    the subclasses c'tor. see also Personality1 for example.
    '''
    '''
    flight or fight skills may need access to the above fusion class booleans
    on the output methode of a skill this skills will load algorithms to the highest priority of the noiron
    which carries algorithms :
    noiron.negativeAlgParts.add(Algorithm)
    '''

    def __init__(self, *absDictionaryDB: AbsDictionaryDB):
        self._dClassesLv1: list[DiSkillV2] = []  # can engage with anyone
        self._dClassesLv2: list[DiSkillV2] = []  # can engage with friends and work related
        self._dClassesLv3: list[DiSkillV2] = []  # can engage only by user
        self._permission: Permission = Permission.newInstance("password", "sweetie", "honey")
        self._dPermitter: DPermitter = DPermitter(self._permission)  # TODO
        self._AlgDurations: dict[str, int] = {}
        self._fusion: Fusion = Fusion(self._AlgDurations)
        # fusion.getReqOverload() # an overload of requests on the brain
        # fusion.getRepReq() // someone is negging and asking the same thing over and over again
        try:
            if (len(absDictionaryDB) == 1):
                self._kokoro = Kokoro(absDictionaryDB[0])
            else:
                self._kokoro = Kokoro(AbsDictionaryDBShadow())
        except:
            self._kokoro = Kokoro(AbsDictionaryDBShadow())

    def getdClassesLv1(self) -> list[DiSkillV2]:
        return self._dClassesLv1

    def getdClassesLv2(self) -> list[DiSkillV2]:
        return self._dClassesLv2

    def getdClassesLv3(self) -> list[DiSkillV2]:
        return self._dClassesLv3

    def getKokoro(self) -> Kokoro:
        return self._kokoro

    def getPermission(self) -> Permission:
        return self._permission

    def getdPermitter(self) -> DPermitter:
        return self._dPermitter

    def getAlgDurations(self) -> dict[str, int]:
        return self._AlgDurations

    def getFusion(self) -> Fusion:
        return self._fusion


if __name__ == "__main__":
    # Permission testing
    print("Permission testing ---")
    permission: Permission = Permission.newInstance("1234", "Mark", "Luke")
    permission.setPermissionLevel("Luke")
    print("Permission level should be 2: " + str(permission.getPermissionLevel()))
    print("Permission level should be 0: " + str(permission.getPermissionLevel()))
    print("setLv1Name should return True: " + str(permission.setLv1Name("1234", "Gregg")))
    print("Lv1Name should be Gregg: " + permission.getLv1Name())

    # DPermitter testing
    print("\nDPermitter testing ---")
    abs: AbsDictionaryDB = AbsDictionaryDBShadow()
    dpermitter: DPermitter = DPermitter(permission)
    dpermitter.input("what is your name my friend?", "", "")
    print("outAlg representation should be 'say Gregg': " + dpermitter.outAlg.representation)
    algo: Algorithm = dpermitter.requipSayAlg("replay")
    print("Representation should be 'say replay': " + algo.getRepresentation)
    print("cases check")
    dpermitter.input("1234 you are chi", "", "")
    AP = dpermitter.outAlg.getAlgParts[0]
    result = AP.action("","","")
    print(result)

    # Personality testing
    print("\nPersonality testing ---")
    personality: Personality = Personality(abs)
    personality._kokoro.setEmot("screaming")
    print("Kokoro emot: " + personality._kokoro.emot)
    personality: Personality = Personality()
    personality._kokoro.setEmot("laughing")
    print("Kokoro emot: " + personality._kokoro.emot)
 
Top