From 922f9950228ee83510378ae25ba5a04da06bec5c Mon Sep 17 00:00:00 2001 From: KyMAN <0kyman0@gmail.com> Date: Mon, 22 Jun 2026 07:37:40 +0200 Subject: [PATCH] #wip: Autoportable Python version. --- JSON/AnP.settings.json | 4 +- JSON/I18N/AnP.i18n.espanol.json | 7 +- Public/ecma/Utils/Common.ecma.js | 6 +- .../Abstracts/AIInterpretersAbstract.py | 6 +- .../{ => AnP}/Abstracts/ControllerAbstract.py | 4 +- .../{ => AnP}/Abstracts/DispatchAbstract.py | 4 +- Python/{ => AnP}/Abstracts/FilesAbstract.py | 13 +- .../Abstracts/HTTPServersAbstract.py | 4 +- Python/{ => AnP}/Abstracts/ModelAbstract.py | 0 Python/{ => AnP}/Abstracts/RouteAbstract.py | 0 .../Abstracts/WebSocketServersAbstract.py | 6 +- Python/{ => AnP}/Abstracts/__init__py | 0 Python/{ => AnP}/Application/AnP.py | 40 +-- Python/{ => AnP}/Application/Event.py | 0 Python/{ => AnP}/Application/__init__py | 0 Python/{ => AnP}/Controllers/AIController.py | 10 +- .../AnP/Controllers/AITranslateController.py | 11 + Python/AnP/Controllers/CloneController.py | 83 +++++ Python/{ => AnP}/Controllers/__init__py | 0 Python/{ => AnP}/Drivers/FilesDriver.py | 42 ++- Python/{ => AnP}/Drivers/HTTPServerDriver.py | 8 +- .../Drivers/HTTPSocketServerDriver.py | 12 +- Python/{ => AnP}/Drivers/OllamaDriver.py | 12 +- .../Drivers/WebSocketServerDriver.py | 8 +- Python/{ => AnP}/Drivers/__init__py | 0 .../Abstracts/FilesAbstractInterface.py | 0 .../Abstracts/HTTPServersAbstractInterface.py | 0 .../WebSocketServersAbstractInterface.py | 0 .../{ => AnP}/Interfaces/Abstracts/__init__py | 0 .../Interfaces/Application/AnPInterface.py | 34 +- .../Interfaces/Application/__init__py | 0 .../AIInterpretersManagerInterface.py | 2 +- .../Managers/ControllersManagerInterface.py | 2 +- .../Managers/DispatchesManagerInterface.py | 0 .../Managers/HTTPServersManagerInterface.py | 2 +- .../Managers/I18NManagerInterface.py | 0 .../Managers/IndexesManagerInterface.py | 0 .../Managers/ModelsManagerInterface.py | 0 .../Managers/PrintTypesManagerInterface.py | 0 .../Managers/PseudoLoRAsManagerInterface.py | 2 +- .../Managers/QueusManagerInterface.py | 0 .../Managers/RoutesManagerInterface.py | 2 +- .../Managers/SessionsManagerInterface.py | 2 +- .../Managers/SettingsManagerInterface.py | 0 .../Managers/TerminalManagerInterface.py | 0 .../Managers/UniqueKeysManagerInterface.py | 0 .../WebSocketServersManagerInterface.py | 4 +- .../{ => AnP}/Interfaces/Managers/__init__py | 0 Python/{ => AnP}/Interfaces/__init__py | 0 .../Managers/AIInterpretersManager.py | 8 +- .../{ => AnP}/Managers/ControllersManager.py | 11 +- .../{ => AnP}/Managers/DispatchesManager.py | 7 +- .../{ => AnP}/Managers/HTTPServersManager.py | 8 +- Python/{ => AnP}/Managers/I18NManager.py | 6 +- Python/{ => AnP}/Managers/IndexesManager.py | 4 +- Python/{ => AnP}/Managers/ModelsManager.py | 8 +- .../{ => AnP}/Managers/PrintTypesManager.py | 6 +- .../{ => AnP}/Managers/PseudoLoRAsManager.py | 6 +- Python/{ => AnP}/Managers/QueusManager.py | 6 +- Python/{ => AnP}/Managers/RoutesManager.py | 11 +- Python/{ => AnP}/Managers/SessionsManager.py | 4 +- Python/{ => AnP}/Managers/SettingsManager.py | 6 +- Python/{ => AnP}/Managers/TerminalManager.py | 10 +- .../{ => AnP}/Managers/UniqueKeysManager.py | 6 +- .../Managers/WebSocketServersManager.py | 12 +- Python/{ => AnP}/Managers/__init__py | 0 Python/{ => AnP}/Models/AIResponseModel.py | 0 Python/{ => AnP}/Models/CommandModel.py | 4 +- Python/AnP/Models/HashModel.py | 73 ++++ Python/{ => AnP}/Models/PseudoLoRAModel.py | 4 +- Python/{ => AnP}/Models/QueuesModel.py | 4 +- Python/{ => AnP}/Models/RequestModel.py | 6 +- Python/{ => AnP}/Models/RouteModel.py | 10 +- Python/{ => AnP}/Models/SessionModel.py | 0 Python/{ => AnP}/Models/__init__py | 0 Python/{ => AnP}/Utils/Checks.py | 4 +- Python/{ => AnP}/Utils/Common.py | 4 +- Python/{ => AnP}/Utils/Patterns.py | 0 Python/{ => AnP}/Utils/__init__py | 0 Python/AnP/__init__.py | 0 Python/base.py | 39 +++ Python/map.anp.py | 312 ------------------ Python/run.py | 37 +-- 83 files changed, 425 insertions(+), 521 deletions(-) rename Python/{ => AnP}/Abstracts/AIInterpretersAbstract.py (95%) rename Python/{ => AnP}/Abstracts/ControllerAbstract.py (65%) rename Python/{ => AnP}/Abstracts/DispatchAbstract.py (64%) rename Python/{ => AnP}/Abstracts/FilesAbstract.py (91%) rename Python/{ => AnP}/Abstracts/HTTPServersAbstract.py (97%) rename Python/{ => AnP}/Abstracts/ModelAbstract.py (100%) rename Python/{ => AnP}/Abstracts/RouteAbstract.py (100%) rename Python/{ => AnP}/Abstracts/WebSocketServersAbstract.py (91%) rename Python/{ => AnP}/Abstracts/__init__py (100%) rename Python/{ => AnP}/Application/AnP.py (84%) rename Python/{ => AnP}/Application/Event.py (100%) rename Python/{ => AnP}/Application/__init__py (100%) rename Python/{ => AnP}/Controllers/AIController.py (91%) create mode 100644 Python/AnP/Controllers/AITranslateController.py create mode 100644 Python/AnP/Controllers/CloneController.py rename Python/{ => AnP}/Controllers/__init__py (100%) rename Python/{ => AnP}/Drivers/FilesDriver.py (67%) rename Python/{ => AnP}/Drivers/HTTPServerDriver.py (94%) rename Python/{ => AnP}/Drivers/HTTPSocketServerDriver.py (95%) rename Python/{ => AnP}/Drivers/OllamaDriver.py (90%) rename Python/{ => AnP}/Drivers/WebSocketServerDriver.py (94%) rename Python/{ => AnP}/Drivers/__init__py (100%) rename Python/{ => AnP}/Interfaces/Abstracts/FilesAbstractInterface.py (100%) rename Python/{ => AnP}/Interfaces/Abstracts/HTTPServersAbstractInterface.py (100%) rename Python/{ => AnP}/Interfaces/Abstracts/WebSocketServersAbstractInterface.py (100%) rename Python/{ => AnP}/Interfaces/Abstracts/__init__py (100%) rename Python/{ => AnP}/Interfaces/Application/AnPInterface.py (57%) rename Python/{ => AnP}/Interfaces/Application/__init__py (100%) rename Python/{ => AnP}/Interfaces/Managers/AIInterpretersManagerInterface.py (87%) rename Python/{ => AnP}/Interfaces/Managers/ControllersManagerInterface.py (87%) rename Python/{ => AnP}/Interfaces/Managers/DispatchesManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/HTTPServersManagerInterface.py (85%) rename Python/{ => AnP}/Interfaces/Managers/I18NManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/IndexesManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/ModelsManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/PrintTypesManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/PseudoLoRAsManagerInterface.py (82%) rename Python/{ => AnP}/Interfaces/Managers/QueusManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/RoutesManagerInterface.py (89%) rename Python/{ => AnP}/Interfaces/Managers/SessionsManagerInterface.py (87%) rename Python/{ => AnP}/Interfaces/Managers/SettingsManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/TerminalManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/UniqueKeysManagerInterface.py (100%) rename Python/{ => AnP}/Interfaces/Managers/WebSocketServersManagerInterface.py (87%) rename Python/{ => AnP}/Interfaces/Managers/__init__py (100%) rename Python/{ => AnP}/Interfaces/__init__py (100%) rename Python/{ => AnP}/Managers/AIInterpretersManager.py (91%) rename Python/{ => AnP}/Managers/ControllersManager.py (87%) rename Python/{ => AnP}/Managers/DispatchesManager.py (90%) rename Python/{ => AnP}/Managers/HTTPServersManager.py (90%) rename Python/{ => AnP}/Managers/I18NManager.py (95%) rename Python/{ => AnP}/Managers/IndexesManager.py (87%) rename Python/{ => AnP}/Managers/ModelsManager.py (85%) rename Python/{ => AnP}/Managers/PrintTypesManager.py (93%) rename Python/{ => AnP}/Managers/PseudoLoRAsManager.py (96%) rename Python/{ => AnP}/Managers/QueusManager.py (94%) rename Python/{ => AnP}/Managers/RoutesManager.py (94%) rename Python/{ => AnP}/Managers/SessionsManager.py (94%) rename Python/{ => AnP}/Managers/SettingsManager.py (92%) rename Python/{ => AnP}/Managers/TerminalManager.py (93%) rename Python/{ => AnP}/Managers/UniqueKeysManager.py (88%) rename Python/{ => AnP}/Managers/WebSocketServersManager.py (93%) rename Python/{ => AnP}/Managers/__init__py (100%) rename Python/{ => AnP}/Models/AIResponseModel.py (100%) rename Python/{ => AnP}/Models/CommandModel.py (88%) create mode 100644 Python/AnP/Models/HashModel.py rename Python/{ => AnP}/Models/PseudoLoRAModel.py (90%) rename Python/{ => AnP}/Models/QueuesModel.py (96%) rename Python/{ => AnP}/Models/RequestModel.py (95%) rename Python/{ => AnP}/Models/RouteModel.py (95%) rename Python/{ => AnP}/Models/SessionModel.py (100%) rename Python/{ => AnP}/Models/__init__py (100%) rename Python/{ => AnP}/Utils/Checks.py (94%) rename Python/{ => AnP}/Utils/Common.py (99%) rename Python/{ => AnP}/Utils/Patterns.py (100%) rename Python/{ => AnP}/Utils/__init__py (100%) create mode 100644 Python/AnP/__init__.py create mode 100644 Python/base.py delete mode 100644 Python/map.anp.py diff --git a/JSON/AnP.settings.json b/JSON/AnP.settings.json index 41151eb..fab2870 100644 --- a/JSON/AnP.settings.json +++ b/JSON/AnP.settings.json @@ -53,7 +53,9 @@ "AnP_ControllersManager_start" : null, "default_controllers" : { - "ai" : "AIController" + "ai" : "AIController", + "clonations_processes" : "CloneController", + "ai_translate" : "AITranslateController" }, "AnP_ControllersManager_end" : null, diff --git a/JSON/I18N/AnP.i18n.espanol.json b/JSON/I18N/AnP.i18n.espanol.json index 0b3acff..83f5bf7 100644 --- a/JSON/I18N/AnP.i18n.espanol.json +++ b/JSON/I18N/AnP.i18n.espanol.json @@ -56,7 +56,12 @@ "Lista de títulos a evaluar: \n{list}" ], "ai_controller_response_system" : "Usa las siguientes guías para responder y dar soporte.{loras}", - "AnP_AIController_end" : null + "AnP_AIController_end" : null, + + "AnP_CloneController_start" : null, + "anp_clone_controller_file_cloned" : "El archivo '{file}' ha sido clonado desde '{from_path}' a '{to_path}'.", + "anp_clone_controller_file_deleted" : "El archivo '{file}' ha sido eliminado de '{to_path}'.", + "AnP_CloneController_end" : null } } \ No newline at end of file diff --git a/Public/ecma/Utils/Common.ecma.js b/Public/ecma/Utils/Common.ecma.js index e011aa4..74ed4f3 100644 --- a/Public/ecma/Utils/Common.ecma.js +++ b/Public/ecma/Utils/Common.ecma.js @@ -338,7 +338,8 @@ export const Common = (function(){ master = ( Check.is_html_item(inputs[0]) ? inputs[0] : Check.is_string(inputs[0]) ? document.querySelector(inputs[0]) : - null); + null), + items = []; (master ? inputs.slice(1) : inputs).forEach(subinputs => { if(Check.is_html_item(subinputs)) @@ -371,9 +372,10 @@ export const Common = (function(){ }; }); + items.push(...fragment.childNodes); master && master.appendChild(fragment); - return [...fragment.childNodes]; + return items; }; /** diff --git a/Python/Abstracts/AIInterpretersAbstract.py b/Python/AnP/Abstracts/AIInterpretersAbstract.py similarity index 95% rename from Python/Abstracts/AIInterpretersAbstract.py rename to Python/AnP/Abstracts/AIInterpretersAbstract.py index 654b61f..611c615 100644 --- a/Python/Abstracts/AIInterpretersAbstract.py +++ b/Python/AnP/Abstracts/AIInterpretersAbstract.py @@ -3,9 +3,9 @@ from typing import Any, Self, Sequence, Optional, Callable from abc import ABC, abstractmethod -from Interfaces.Application.AnPInterface import AnPInterface -from Models.AIResponseModel import AIResponseModel -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Models.AIResponseModel import AIResponseModel +from AnP.Utils.Checks import Check class AIInterpretersAbstract(ABC): diff --git a/Python/Abstracts/ControllerAbstract.py b/Python/AnP/Abstracts/ControllerAbstract.py similarity index 65% rename from Python/Abstracts/ControllerAbstract.py rename to Python/AnP/Abstracts/ControllerAbstract.py index 286993f..5cc54c7 100644 --- a/Python/Abstracts/ControllerAbstract.py +++ b/Python/AnP/Abstracts/ControllerAbstract.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- from typing import Self, Any, Optional, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.ModelAbstract import ModelAbstract +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.ModelAbstract import ModelAbstract class ControllerAbstract(ModelAbstract): diff --git a/Python/Abstracts/DispatchAbstract.py b/Python/AnP/Abstracts/DispatchAbstract.py similarity index 64% rename from Python/Abstracts/DispatchAbstract.py rename to Python/AnP/Abstracts/DispatchAbstract.py index c3c31b4..5792736 100644 --- a/Python/Abstracts/DispatchAbstract.py +++ b/Python/AnP/Abstracts/DispatchAbstract.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- from typing import Self, Any, Optional, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.ModelAbstract import ModelAbstract +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.ModelAbstract import ModelAbstract class DispatchAbstract(ModelAbstract): diff --git a/Python/Abstracts/FilesAbstract.py b/Python/AnP/Abstracts/FilesAbstract.py similarity index 91% rename from Python/Abstracts/FilesAbstract.py rename to Python/AnP/Abstracts/FilesAbstract.py index f6e2681..d2b9509 100644 --- a/Python/Abstracts/FilesAbstract.py +++ b/Python/AnP/Abstracts/FilesAbstract.py @@ -4,10 +4,10 @@ from typing import Any, Optional, Self, Sequence from abc import ABC, abstractmethod from os.path import dirname as directory_name, abspath as absolute_path -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Common import Common -from Utils.Checks import Check -from Utils.Patterns import RE +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check +from AnP.Utils.Patterns import RE class FilesAbstract(ABC): @@ -92,4 +92,7 @@ class FilesAbstract(ABC): else: results.extend(self.load_json(json, only_dictionaries)) - return results \ No newline at end of file + return results + + @abstractmethod + def list_directory_items(self:Self, path:str) -> list[str]:pass \ No newline at end of file diff --git a/Python/Abstracts/HTTPServersAbstract.py b/Python/AnP/Abstracts/HTTPServersAbstract.py similarity index 97% rename from Python/Abstracts/HTTPServersAbstract.py rename to Python/AnP/Abstracts/HTTPServersAbstract.py index 6c0017f..2a24e6c 100644 --- a/Python/Abstracts/HTTPServersAbstract.py +++ b/Python/AnP/Abstracts/HTTPServersAbstract.py @@ -5,8 +5,8 @@ from abc import ABC, abstractmethod from typing import Any, Self, Optional, Sequence from re import Match as REMath import datetime -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Common import Common +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Common import Common class HTTPServersAbstract(ABC): diff --git a/Python/Abstracts/ModelAbstract.py b/Python/AnP/Abstracts/ModelAbstract.py similarity index 100% rename from Python/Abstracts/ModelAbstract.py rename to Python/AnP/Abstracts/ModelAbstract.py diff --git a/Python/Abstracts/RouteAbstract.py b/Python/AnP/Abstracts/RouteAbstract.py similarity index 100% rename from Python/Abstracts/RouteAbstract.py rename to Python/AnP/Abstracts/RouteAbstract.py diff --git a/Python/Abstracts/WebSocketServersAbstract.py b/Python/AnP/Abstracts/WebSocketServersAbstract.py similarity index 91% rename from Python/Abstracts/WebSocketServersAbstract.py rename to Python/AnP/Abstracts/WebSocketServersAbstract.py index 7036fde..836f4a1 100644 --- a/Python/Abstracts/WebSocketServersAbstract.py +++ b/Python/AnP/Abstracts/WebSocketServersAbstract.py @@ -3,9 +3,9 @@ from typing import Any, Self, Optional, Sequence from abc import ABC, abstractmethod -from Interfaces.Application.AnPInterface import AnPInterface -from Application.Event import Event -from Utils.Common import Common +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Application.Event import Event +from AnP.Utils.Common import Common class WebSocketServersAbstract(ABC): diff --git a/Python/Abstracts/__init__py b/Python/AnP/Abstracts/__init__py similarity index 100% rename from Python/Abstracts/__init__py rename to Python/AnP/Abstracts/__init__py diff --git a/Python/Application/AnP.py b/Python/AnP/Application/AnP.py similarity index 84% rename from Python/Application/AnP.py rename to Python/AnP/Application/AnP.py index ddff67e..7d95c22 100644 --- a/Python/Application/AnP.py +++ b/Python/AnP/Application/AnP.py @@ -6,26 +6,26 @@ import datetime from re import Match as REMatch from traceback import extract_tb as extract_traceback, format_stack as trace_format_stack from time import time as timestamp, sleep -from Abstracts.FilesAbstract import FilesAbstract -from Drivers.FilesDriver import FilesDriver -from Managers.I18NManager import I18NManager -from Managers.SettingsManager import SettingsManager -from Managers.PrintTypesManager import PrintTypesManager -from Managers.TerminalManager import TerminalManager -from Managers.ModelsManager import ModelsManager -from Managers.UniqueKeysManager import UniqueKeysManager -from Managers.QueusManager import QueuesManager -from Managers.SessionsManager import SessionsManager -from Managers.ControllersManager import ControllersManager -from Managers.DispatchesManager import DispatchesManager -from Managers.IndexesManager import IndexesManager -from Managers.RoutesManager import RoutesManager -from Managers.WebSocketServersManager import WebSocketServersManager -from Managers.HTTPServersManager import HTTPServersManager -from Managers.PseudoLoRAsManager import PseudoLoRAsManager -from Managers.AIInterpretersManager import AIInterpretersManager -from Utils.Common import Common -from Utils.Patterns import RE +from AnP.Abstracts.FilesAbstract import FilesAbstract +from AnP.Drivers.FilesDriver import FilesDriver +from AnP.Managers.I18NManager import I18NManager +from AnP.Managers.SettingsManager import SettingsManager +from AnP.Managers.PrintTypesManager import PrintTypesManager +from AnP.Managers.TerminalManager import TerminalManager +from AnP.Managers.ModelsManager import ModelsManager +from AnP.Managers.UniqueKeysManager import UniqueKeysManager +from AnP.Managers.QueusManager import QueuesManager +from AnP.Managers.SessionsManager import SessionsManager +from AnP.Managers.ControllersManager import ControllersManager +from AnP.Managers.DispatchesManager import DispatchesManager +from AnP.Managers.IndexesManager import IndexesManager +from AnP.Managers.RoutesManager import RoutesManager +from AnP.Managers.WebSocketServersManager import WebSocketServersManager +from AnP.Managers.HTTPServersManager import HTTPServersManager +from AnP.Managers.PseudoLoRAsManager import PseudoLoRAsManager +from AnP.Managers.AIInterpretersManager import AIInterpretersManager +from AnP.Utils.Common import Common +from AnP.Utils.Patterns import RE class AnP: diff --git a/Python/Application/Event.py b/Python/AnP/Application/Event.py similarity index 100% rename from Python/Application/Event.py rename to Python/AnP/Application/Event.py diff --git a/Python/Application/__init__py b/Python/AnP/Application/__init__py similarity index 100% rename from Python/Application/__init__py rename to Python/AnP/Application/__init__py diff --git a/Python/Controllers/AIController.py b/Python/AnP/Controllers/AIController.py similarity index 91% rename from Python/Controllers/AIController.py rename to Python/AnP/Controllers/AIController.py index 71223f7..a200a3f 100644 --- a/Python/Controllers/AIController.py +++ b/Python/AnP/Controllers/AIController.py @@ -2,11 +2,11 @@ # -*- coding: utf-8 -*- from typing import Self, Callable -from Abstracts.ModelAbstract import ModelAbstract -from Abstracts.ControllerAbstract import ControllerAbstract -from Models.RequestModel import RequestModel -from Models.AIResponseModel import AIResponseModel -from Utils.Common import Common +from AnP.Abstracts.ModelAbstract import ModelAbstract +from AnP.Abstracts.ControllerAbstract import ControllerAbstract +from AnP.Models.RequestModel import RequestModel +from AnP.Models.AIResponseModel import AIResponseModel +from AnP.Utils.Common import Common class AIController(ControllerAbstract, ModelAbstract): diff --git a/Python/AnP/Controllers/AITranslateController.py b/Python/AnP/Controllers/AITranslateController.py new file mode 100644 index 0000000..411c686 --- /dev/null +++ b/Python/AnP/Controllers/AITranslateController.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from typing import Self +from AnP.Abstracts.ControllerAbstract import ControllerAbstract +from AnP.Models.RequestModel import RequestModel + +class AITranslateController(ControllerAbstract): + + def translate(self:Self, request:RequestModel) -> None: + pass \ No newline at end of file diff --git a/Python/AnP/Controllers/CloneController.py b/Python/AnP/Controllers/CloneController.py new file mode 100644 index 0000000..fe61bda --- /dev/null +++ b/Python/AnP/Controllers/CloneController.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from typing import Self +from threading import Thread +from AnP.Abstracts.ControllerAbstract import ControllerAbstract +from AnP.Models.RequestModel import RequestModel +from AnP.Models.HashModel import HashModel + +class CloneController(ControllerAbstract): + + def __clone_subdirectory(self:Self, from_path:str, to_path:str, hashes:dict[str, HashModel], ignore:list[str]) -> None: + + item:str + current_items:list[str] = self.anp.files.list_directory_items(to_path, True) + + if not self.anp.files.exists(to_path): + self.anp.files.make_directory(to_path) + + for item in self.anp.files.list_directory_items(from_path, True): + + if item in current_items: + current_items.remove(item) + + if item in ignore or item in (".", ".."): + continue + + from_item_path:str = f"{from_path}/{item}" + to_item_path:str = f"{to_path}/{item}" + + if self.anp.files.is_directory(from_item_path): + self.__clone_subdirectory(from_item_path, to_item_path, hashes, ignore) + elif self.anp.files.is_file(from_item_path): + + data:bytes = self.anp.files.load(from_item_path, "rb") + hash:HashModel = HashModel(data) + + if self.anp.files.exists(to_item_path) and to_item_path not in hashes: + hashes[to_item_path] = HashModel(self.anp.files.load(to_item_path, "rb")) + + if to_item_path not in hashes or not hash.compare(hashes[to_item_path]): + self.anp.files.save(to_item_path, data) + hashes[to_item_path] = hash + self.anp.print("info", "anp_clone_controller_file_cloned", { + "from_item_path" : from_item_path, + "to_item_path" : to_item_path, + "from_path" : from_path, + "to_path" : to_path, + "file" : item + }) + + for item in current_items: + self.anp.files.delete(f"{to_path}/{item}") + self.anp.print("info", "anp_clone_controller_file_deleted", { + "to_item_path" : f"{to_path}/{item}", + "to_path" : to_path, + "file" : item + }) + + def __clone_process(self:Self, from_path:str, to_path:str, waiter:int|float, ignore:list[str]) -> None: + + hashes:dict[str, HashModel] = {} + waiter /= 1000.0 + + while self.anp.working(): + self.__clone_subdirectory(from_path, to_path, hashes, ignore) + self.anp.wait(waiter) + + def __clone_directory(self:Self, from_path:str, to_path:str, waiter:int|float, ignore:list[str]) -> None: + Thread(target = self.__clone_process, args = (from_path, to_path, waiter, ignore)).start() + + def clone(self:Self, request:RequestModel) -> None: # Not use from Routes. + self.__clone_directory(request.get("from_path", ""), request.get("to_path", ""), request.get("waiter", 5000), request.get("ignore", [])) + + def execute(self:Self, _) -> None: # Not use from Routes. + + from_path:str + to_path:str + waiter:int|float + ignore:list[str] + + for (from_path, to_path, waiter, ignore) in self.anp.settings.get("clonations_processes", []): + self.__clone_directory(from_path, to_path, waiter, ignore) \ No newline at end of file diff --git a/Python/Controllers/__init__py b/Python/AnP/Controllers/__init__py similarity index 100% rename from Python/Controllers/__init__py rename to Python/AnP/Controllers/__init__py diff --git a/Python/Drivers/FilesDriver.py b/Python/AnP/Drivers/FilesDriver.py similarity index 67% rename from Python/Drivers/FilesDriver.py rename to Python/AnP/Drivers/FilesDriver.py index 1484dc6..3ffaf1d 100644 --- a/Python/Drivers/FilesDriver.py +++ b/Python/AnP/Drivers/FilesDriver.py @@ -3,10 +3,17 @@ from typing import Self from os.path import isfile as is_file, isdir as is_directory, exists as path_exists -from os import unlink as delete_path, mkdir as make_directory -from Abstracts.FilesAbstract import FilesAbstract -from Abstracts.ModelAbstract import ModelAbstract -from Utils.Checks import Check +from os import ( + unlink as delete_symbolic_link, + remove as delete_file, + # rmdir as remove_directory, + mkdir as make_directory, + listdir as list_directory_items +) +from shutil import rmtree as remove_directory +from AnP.Abstracts.FilesAbstract import FilesAbstract +from AnP.Abstracts.ModelAbstract import ModelAbstract +from AnP.Utils.Checks import Check class FilesDriver(FilesAbstract, ModelAbstract): @@ -87,11 +94,34 @@ class FilesDriver(FilesAbstract, ModelAbstract): if absolute_path: try: - delete_path(absolute_path) + if is_file(absolute_path): + delete_file(absolute_path) + elif is_directory(absolute_path): + remove_directory(absolute_path) + else: + delete_symbolic_link(absolute_path) return True except Exception as exception: self.anp.exception(exception, "anp_files_driver_delete_exception", { "path" : path, "absolute_path" : absolute_path }) - return False \ No newline at end of file + return False + + def list_directory_items(self:Self, path:str, only_names:bool = True) -> list[str]: + + items:list[str] = [] + absolute_path:str = self.get_absolute_path(path) + + if absolute_path is not None and self.is_directory(absolute_path): + try: + if only_names: + items.extend(list_directory_items(absolute_path)) + else: + items.extend([f"{absolute_path}{self._slash}{item}" for item in list_directory_items(absolute_path)]) + except Exception as exception: + self.anp.exception(exception, "anp_files_driver_list_directory_items_exception", { + "path" : path, + "only_names" : only_names + }) + return items \ No newline at end of file diff --git a/Python/Drivers/HTTPServerDriver.py b/Python/AnP/Drivers/HTTPServerDriver.py similarity index 94% rename from Python/Drivers/HTTPServerDriver.py rename to Python/AnP/Drivers/HTTPServerDriver.py index b336d26..19c0bdb 100644 --- a/Python/Drivers/HTTPServerDriver.py +++ b/Python/AnP/Drivers/HTTPServerDriver.py @@ -2,13 +2,13 @@ # -*- coding: utf-8 -*- from typing import Any, Optional, Self, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.ModelAbstract import ModelAbstract -from Models.RequestModel import RequestModel from threading import Thread from http.server import BaseHTTPRequestHandler, HTTPServer from http.cookies import SimpleCookie -from Abstracts.HTTPServersAbstract import HTTPServersAbstract +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.ModelAbstract import ModelAbstract +from AnP.Models.RequestModel import RequestModel +from AnP.Abstracts.HTTPServersAbstract import HTTPServersAbstract class HTTPServerDriver(HTTPServersAbstract, ModelAbstract): diff --git a/Python/Drivers/HTTPSocketServerDriver.py b/Python/AnP/Drivers/HTTPSocketServerDriver.py similarity index 95% rename from Python/Drivers/HTTPSocketServerDriver.py rename to Python/AnP/Drivers/HTTPSocketServerDriver.py index 69fd009..6625587 100644 --- a/Python/Drivers/HTTPSocketServerDriver.py +++ b/Python/AnP/Drivers/HTTPSocketServerDriver.py @@ -11,12 +11,12 @@ from socket import ( SO_REUSEADDR as SOCKET_REUSE_ADDRESS ) import datetime -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.HTTPServersAbstract import HTTPServersAbstract -from Models.RequestModel import RequestModel -from Utils.Common import Common -from Utils.Checks import Check -from Utils.Patterns import RE +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.HTTPServersAbstract import HTTPServersAbstract +from AnP.Models.RequestModel import RequestModel +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check +from AnP.Utils.Patterns import RE class HTTPSocketServerDriver(HTTPServersAbstract): diff --git a/Python/Drivers/OllamaDriver.py b/Python/AnP/Drivers/OllamaDriver.py similarity index 90% rename from Python/Drivers/OllamaDriver.py rename to Python/AnP/Drivers/OllamaDriver.py index 00526ea..448b6a9 100644 --- a/Python/Drivers/OllamaDriver.py +++ b/Python/AnP/Drivers/OllamaDriver.py @@ -4,12 +4,12 @@ from typing import Any, Optional, Self, Sequence, Callable from requests import post as Post, Response # from pydantic import BaseModel -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.AIInterpretersAbstract import AIInterpretersAbstract -from Abstracts.ModelAbstract import ModelAbstract -from Models.AIResponseModel import AIResponseModel -from Utils.Checks import Check -from Utils.Common import Common +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.AIInterpretersAbstract import AIInterpretersAbstract +from AnP.Abstracts.ModelAbstract import ModelAbstract +from AnP.Models.AIResponseModel import AIResponseModel +from AnP.Utils.Checks import Check +from AnP.Utils.Common import Common class OllamaDriver(AIInterpretersAbstract, ModelAbstract): diff --git a/Python/Drivers/WebSocketServerDriver.py b/Python/AnP/Drivers/WebSocketServerDriver.py similarity index 94% rename from Python/Drivers/WebSocketServerDriver.py rename to Python/AnP/Drivers/WebSocketServerDriver.py index bc80be4..9826191 100644 --- a/Python/Drivers/WebSocketServerDriver.py +++ b/Python/AnP/Drivers/WebSocketServerDriver.py @@ -4,12 +4,12 @@ from threading import Thread from typing import Any, Self, Sequence, Optional from http.cookies import SimpleCookie -from Abstracts.WebSocketServersAbstract import WebSocketServersAbstract -from Abstracts.ModelAbstract import ModelAbstract from websockets.sync.server import serve as server_serve from websockets import Server as WebSocketServer, ClientConnection as WebSocketClient -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Checks import Check +from AnP.Abstracts.WebSocketServersAbstract import WebSocketServersAbstract +from AnP.Abstracts.ModelAbstract import ModelAbstract +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Checks import Check class WebSocketServerDriver(WebSocketServersAbstract, ModelAbstract): diff --git a/Python/Drivers/__init__py b/Python/AnP/Drivers/__init__py similarity index 100% rename from Python/Drivers/__init__py rename to Python/AnP/Drivers/__init__py diff --git a/Python/Interfaces/Abstracts/FilesAbstractInterface.py b/Python/AnP/Interfaces/Abstracts/FilesAbstractInterface.py similarity index 100% rename from Python/Interfaces/Abstracts/FilesAbstractInterface.py rename to Python/AnP/Interfaces/Abstracts/FilesAbstractInterface.py diff --git a/Python/Interfaces/Abstracts/HTTPServersAbstractInterface.py b/Python/AnP/Interfaces/Abstracts/HTTPServersAbstractInterface.py similarity index 100% rename from Python/Interfaces/Abstracts/HTTPServersAbstractInterface.py rename to Python/AnP/Interfaces/Abstracts/HTTPServersAbstractInterface.py diff --git a/Python/Interfaces/Abstracts/WebSocketServersAbstractInterface.py b/Python/AnP/Interfaces/Abstracts/WebSocketServersAbstractInterface.py similarity index 100% rename from Python/Interfaces/Abstracts/WebSocketServersAbstractInterface.py rename to Python/AnP/Interfaces/Abstracts/WebSocketServersAbstractInterface.py diff --git a/Python/Interfaces/Abstracts/__init__py b/Python/AnP/Interfaces/Abstracts/__init__py similarity index 100% rename from Python/Interfaces/Abstracts/__init__py rename to Python/AnP/Interfaces/Abstracts/__init__py diff --git a/Python/Interfaces/Application/AnPInterface.py b/Python/AnP/Interfaces/Application/AnPInterface.py similarity index 57% rename from Python/Interfaces/Application/AnPInterface.py rename to Python/AnP/Interfaces/Application/AnPInterface.py index 24ae6df..ab835d8 100644 --- a/Python/Interfaces/Application/AnPInterface.py +++ b/Python/AnP/Interfaces/Application/AnPInterface.py @@ -3,23 +3,23 @@ from typing import Any, Optional, Sequence, Self from abc import ABC, abstractmethod -from Interfaces.Managers.SettingsManagerInterface import SettingsManagerInterface -from Interfaces.Managers.I18NManagerInterface import I18NManagerInterface -from Interfaces.Managers.PrintTypesManagerInterface import PrintTypesManagerInterface -from Interfaces.Managers.TerminalManagerInterface import TerminalManagerInterface -from Interfaces.Abstracts.FilesAbstractInterface import FilesAbstractInterface -from Interfaces.Managers.ModelsManagerInterface import ModelsManagerInterface -from Interfaces.Managers.UniqueKeysManagerInterface import UniqueKeysManagerInterface -from Interfaces.Managers.QueusManagerInterface import QueusManagerInterface -from Interfaces.Managers.SessionsManagerInterface import SessionsManagerInterface -from Interfaces.Managers.ControllersManagerInterface import ControllersManagerInterface -from Interfaces.Managers.DispatchesManagerInterface import DispatchesManagerInterface -from Interfaces.Managers.IndexesManagerInterface import IndexesManagerInterface -from Interfaces.Managers.RoutesManagerInterface import RoutesManagerInterface -from Interfaces.Managers.WebSocketServersManagerInterface import WebSocketServersManagerInterface -from Interfaces.Managers.HTTPServersManagerInterface import HTTPServersManagerInterface -from Interfaces.Managers.PseudoLoRAsManagerInterface import PseudoLoRAsManagerInterface -from Interfaces.Managers.AIInterpretersManagerInterface import AIInterpretersManagerInterface +from AnP.Interfaces.Managers.SettingsManagerInterface import SettingsManagerInterface +from AnP.Interfaces.Managers.I18NManagerInterface import I18NManagerInterface +from AnP.Interfaces.Managers.PrintTypesManagerInterface import PrintTypesManagerInterface +from AnP.Interfaces.Managers.TerminalManagerInterface import TerminalManagerInterface +from AnP.Interfaces.Abstracts.FilesAbstractInterface import FilesAbstractInterface +from AnP.Interfaces.Managers.ModelsManagerInterface import ModelsManagerInterface +from AnP.Interfaces.Managers.UniqueKeysManagerInterface import UniqueKeysManagerInterface +from AnP.Interfaces.Managers.QueusManagerInterface import QueusManagerInterface +from AnP.Interfaces.Managers.SessionsManagerInterface import SessionsManagerInterface +from AnP.Interfaces.Managers.ControllersManagerInterface import ControllersManagerInterface +from AnP.Interfaces.Managers.DispatchesManagerInterface import DispatchesManagerInterface +from AnP.Interfaces.Managers.IndexesManagerInterface import IndexesManagerInterface +from AnP.Interfaces.Managers.RoutesManagerInterface import RoutesManagerInterface +from AnP.Interfaces.Managers.WebSocketServersManagerInterface import WebSocketServersManagerInterface +from AnP.Interfaces.Managers.HTTPServersManagerInterface import HTTPServersManagerInterface +from AnP.Interfaces.Managers.PseudoLoRAsManagerInterface import PseudoLoRAsManagerInterface +from AnP.Interfaces.Managers.AIInterpretersManagerInterface import AIInterpretersManagerInterface class AnPInterface(ABC): diff --git a/Python/Interfaces/Application/__init__py b/Python/AnP/Interfaces/Application/__init__py similarity index 100% rename from Python/Interfaces/Application/__init__py rename to Python/AnP/Interfaces/Application/__init__py diff --git a/Python/Interfaces/Managers/AIInterpretersManagerInterface.py b/Python/AnP/Interfaces/Managers/AIInterpretersManagerInterface.py similarity index 87% rename from Python/Interfaces/Managers/AIInterpretersManagerInterface.py rename to Python/AnP/Interfaces/Managers/AIInterpretersManagerInterface.py index 78a35d8..6949151 100644 --- a/Python/Interfaces/Managers/AIInterpretersManagerInterface.py +++ b/Python/AnP/Interfaces/Managers/AIInterpretersManagerInterface.py @@ -3,7 +3,7 @@ from typing import Any, Callable, Self, Optional from abc import ABC, abstractmethod -from Models.AIResponseModel import AIResponseModel +from AnP.Models.AIResponseModel import AIResponseModel class AIInterpretersManagerInterface(ABC): diff --git a/Python/Interfaces/Managers/ControllersManagerInterface.py b/Python/AnP/Interfaces/Managers/ControllersManagerInterface.py similarity index 87% rename from Python/Interfaces/Managers/ControllersManagerInterface.py rename to Python/AnP/Interfaces/Managers/ControllersManagerInterface.py index 7e3dc81..f1d430f 100644 --- a/Python/Interfaces/Managers/ControllersManagerInterface.py +++ b/Python/AnP/Interfaces/Managers/ControllersManagerInterface.py @@ -3,7 +3,7 @@ from typing import Any, Self from abc import ABC, abstractmethod -from Models.RequestModel import RequestModel +from AnP.Models.RequestModel import RequestModel class ControllersManagerInterface(ABC): diff --git a/Python/Interfaces/Managers/DispatchesManagerInterface.py b/Python/AnP/Interfaces/Managers/DispatchesManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/DispatchesManagerInterface.py rename to Python/AnP/Interfaces/Managers/DispatchesManagerInterface.py diff --git a/Python/Interfaces/Managers/HTTPServersManagerInterface.py b/Python/AnP/Interfaces/Managers/HTTPServersManagerInterface.py similarity index 85% rename from Python/Interfaces/Managers/HTTPServersManagerInterface.py rename to Python/AnP/Interfaces/Managers/HTTPServersManagerInterface.py index 37ecaff..a99fbcc 100644 --- a/Python/Interfaces/Managers/HTTPServersManagerInterface.py +++ b/Python/AnP/Interfaces/Managers/HTTPServersManagerInterface.py @@ -3,7 +3,7 @@ from typing import Self, Sequence, Any from abc import ABC, abstractmethod -from Interfaces.Abstracts.HTTPServersAbstractInterface import HTTPServersAbstractInterface +from AnP.Interfaces.Abstracts.HTTPServersAbstractInterface import HTTPServersAbstractInterface class HTTPServersManagerInterface(ABC): diff --git a/Python/Interfaces/Managers/I18NManagerInterface.py b/Python/AnP/Interfaces/Managers/I18NManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/I18NManagerInterface.py rename to Python/AnP/Interfaces/Managers/I18NManagerInterface.py diff --git a/Python/Interfaces/Managers/IndexesManagerInterface.py b/Python/AnP/Interfaces/Managers/IndexesManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/IndexesManagerInterface.py rename to Python/AnP/Interfaces/Managers/IndexesManagerInterface.py diff --git a/Python/Interfaces/Managers/ModelsManagerInterface.py b/Python/AnP/Interfaces/Managers/ModelsManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/ModelsManagerInterface.py rename to Python/AnP/Interfaces/Managers/ModelsManagerInterface.py diff --git a/Python/Interfaces/Managers/PrintTypesManagerInterface.py b/Python/AnP/Interfaces/Managers/PrintTypesManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/PrintTypesManagerInterface.py rename to Python/AnP/Interfaces/Managers/PrintTypesManagerInterface.py diff --git a/Python/Interfaces/Managers/PseudoLoRAsManagerInterface.py b/Python/AnP/Interfaces/Managers/PseudoLoRAsManagerInterface.py similarity index 82% rename from Python/Interfaces/Managers/PseudoLoRAsManagerInterface.py rename to Python/AnP/Interfaces/Managers/PseudoLoRAsManagerInterface.py index 904d316..f1bf5d6 100644 --- a/Python/Interfaces/Managers/PseudoLoRAsManagerInterface.py +++ b/Python/AnP/Interfaces/Managers/PseudoLoRAsManagerInterface.py @@ -3,7 +3,7 @@ from typing import Self, Any, Callable from abc import ABC, abstractmethod -from Models.PseudoLoRAModel import PseudoLoRAModel +from AnP.Models.PseudoLoRAModel import PseudoLoRAModel class PseudoLoRAsManagerInterface(ABC): diff --git a/Python/Interfaces/Managers/QueusManagerInterface.py b/Python/AnP/Interfaces/Managers/QueusManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/QueusManagerInterface.py rename to Python/AnP/Interfaces/Managers/QueusManagerInterface.py diff --git a/Python/Interfaces/Managers/RoutesManagerInterface.py b/Python/AnP/Interfaces/Managers/RoutesManagerInterface.py similarity index 89% rename from Python/Interfaces/Managers/RoutesManagerInterface.py rename to Python/AnP/Interfaces/Managers/RoutesManagerInterface.py index 80b182f..895e5d1 100644 --- a/Python/Interfaces/Managers/RoutesManagerInterface.py +++ b/Python/AnP/Interfaces/Managers/RoutesManagerInterface.py @@ -3,7 +3,7 @@ from typing import Self, Any from abc import ABC, abstractmethod -from Models.RequestModel import RequestModel +from AnP.Models.RequestModel import RequestModel class RoutesManagerInterface(ABC): diff --git a/Python/Interfaces/Managers/SessionsManagerInterface.py b/Python/AnP/Interfaces/Managers/SessionsManagerInterface.py similarity index 87% rename from Python/Interfaces/Managers/SessionsManagerInterface.py rename to Python/AnP/Interfaces/Managers/SessionsManagerInterface.py index 759ae20..a67969a 100644 --- a/Python/Interfaces/Managers/SessionsManagerInterface.py +++ b/Python/AnP/Interfaces/Managers/SessionsManagerInterface.py @@ -3,7 +3,7 @@ from typing import Self, Optional, Any from abc import ABC, abstractmethod -from Models.SessionModel import SessionModel +from AnP.Models.SessionModel import SessionModel class SessionsManagerInterface(ABC): diff --git a/Python/Interfaces/Managers/SettingsManagerInterface.py b/Python/AnP/Interfaces/Managers/SettingsManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/SettingsManagerInterface.py rename to Python/AnP/Interfaces/Managers/SettingsManagerInterface.py diff --git a/Python/Interfaces/Managers/TerminalManagerInterface.py b/Python/AnP/Interfaces/Managers/TerminalManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/TerminalManagerInterface.py rename to Python/AnP/Interfaces/Managers/TerminalManagerInterface.py diff --git a/Python/Interfaces/Managers/UniqueKeysManagerInterface.py b/Python/AnP/Interfaces/Managers/UniqueKeysManagerInterface.py similarity index 100% rename from Python/Interfaces/Managers/UniqueKeysManagerInterface.py rename to Python/AnP/Interfaces/Managers/UniqueKeysManagerInterface.py diff --git a/Python/Interfaces/Managers/WebSocketServersManagerInterface.py b/Python/AnP/Interfaces/Managers/WebSocketServersManagerInterface.py similarity index 87% rename from Python/Interfaces/Managers/WebSocketServersManagerInterface.py rename to Python/AnP/Interfaces/Managers/WebSocketServersManagerInterface.py index 9ebe864..03e92c4 100644 --- a/Python/Interfaces/Managers/WebSocketServersManagerInterface.py +++ b/Python/AnP/Interfaces/Managers/WebSocketServersManagerInterface.py @@ -3,8 +3,8 @@ from typing import Any, Self, Optional, Sequence from abc import ABC, abstractmethod -from Interfaces.Abstracts.WebSocketServersAbstractInterface import WebSocketServersAbstractInterface -from Application.Event import Event +from AnP.Interfaces.Abstracts.WebSocketServersAbstractInterface import WebSocketServersAbstractInterface +from AnP.Application.Event import Event class WebSocketServersManagerInterface(ABC): diff --git a/Python/Interfaces/Managers/__init__py b/Python/AnP/Interfaces/Managers/__init__py similarity index 100% rename from Python/Interfaces/Managers/__init__py rename to Python/AnP/Interfaces/Managers/__init__py diff --git a/Python/Interfaces/__init__py b/Python/AnP/Interfaces/__init__py similarity index 100% rename from Python/Interfaces/__init__py rename to Python/AnP/Interfaces/__init__py diff --git a/Python/Managers/AIInterpretersManager.py b/Python/AnP/Managers/AIInterpretersManager.py similarity index 91% rename from Python/Managers/AIInterpretersManager.py rename to Python/AnP/Managers/AIInterpretersManager.py index 27081e0..d1f04ff 100644 --- a/Python/Managers/AIInterpretersManager.py +++ b/Python/AnP/Managers/AIInterpretersManager.py @@ -2,10 +2,10 @@ # -*- coding: utf-8 -*- from typing import Any, Callable, Self, Optional -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.AIInterpretersAbstract import AIInterpretersAbstract -from Models.AIResponseModel import AIResponseModel -from Utils.Common import Common +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.AIInterpretersAbstract import AIInterpretersAbstract +from AnP.Models.AIResponseModel import AIResponseModel +from AnP.Utils.Common import Common class AIInterpretersManager: diff --git a/Python/Managers/ControllersManager.py b/Python/AnP/Managers/ControllersManager.py similarity index 87% rename from Python/Managers/ControllersManager.py rename to Python/AnP/Managers/ControllersManager.py index fd6616e..8b2fe39 100644 --- a/Python/Managers/ControllersManager.py +++ b/Python/AnP/Managers/ControllersManager.py @@ -1,12 +1,11 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from typing import Any, Self, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.ControllerAbstract import ControllerAbstract -from Models.RequestModel import RequestModel -from Utils.Common import Common -from Utils.Checks import Check +from typing import Any, Self +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.ControllerAbstract import ControllerAbstract +from AnP.Models.RequestModel import RequestModel +from AnP.Utils.Checks import Check class ControllersManager: diff --git a/Python/Managers/DispatchesManager.py b/Python/AnP/Managers/DispatchesManager.py similarity index 90% rename from Python/Managers/DispatchesManager.py rename to Python/AnP/Managers/DispatchesManager.py index 773a2e7..6aef946 100644 --- a/Python/Managers/DispatchesManager.py +++ b/Python/AnP/Managers/DispatchesManager.py @@ -2,10 +2,9 @@ # -*- coding: utf-8 -*- from typing import Any, Self -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.DispatchAbstract import DispatchAbstract -from Utils.Common import Common -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.DispatchAbstract import DispatchAbstract +from AnP.Utils.Checks import Check class DispatchesManager: diff --git a/Python/Managers/HTTPServersManager.py b/Python/AnP/Managers/HTTPServersManager.py similarity index 90% rename from Python/Managers/HTTPServersManager.py rename to Python/AnP/Managers/HTTPServersManager.py index a56cc4b..ec27d44 100644 --- a/Python/Managers/HTTPServersManager.py +++ b/Python/AnP/Managers/HTTPServersManager.py @@ -2,10 +2,10 @@ # -*- coding: utf-8 -*- from typing import Self, Sequence, Any -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.HTTPServersAbstract import HTTPServersAbstract -from Utils.Common import Common -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.HTTPServersAbstract import HTTPServersAbstract +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check class HTTPServersManager: diff --git a/Python/Managers/I18NManager.py b/Python/AnP/Managers/I18NManager.py similarity index 95% rename from Python/Managers/I18NManager.py rename to Python/AnP/Managers/I18NManager.py index d7d8caa..9f16b1d 100644 --- a/Python/Managers/I18NManager.py +++ b/Python/AnP/Managers/I18NManager.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- from typing import Any, Optional, Self, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Checks import Check -from Utils.Common import Common +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Checks import Check +from AnP.Utils.Common import Common class I18NManager: diff --git a/Python/Managers/IndexesManager.py b/Python/AnP/Managers/IndexesManager.py similarity index 87% rename from Python/Managers/IndexesManager.py rename to Python/AnP/Managers/IndexesManager.py index fb90279..b891fff 100644 --- a/Python/Managers/IndexesManager.py +++ b/Python/AnP/Managers/IndexesManager.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- from typing import Self, Any -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Checks import Check class IndexesManager: diff --git a/Python/Managers/ModelsManager.py b/Python/AnP/Managers/ModelsManager.py similarity index 85% rename from Python/Managers/ModelsManager.py rename to Python/AnP/Managers/ModelsManager.py index 29a8bad..feee3bd 100644 --- a/Python/Managers/ModelsManager.py +++ b/Python/AnP/Managers/ModelsManager.py @@ -2,10 +2,10 @@ # -*- coding: utf-8 -*- from typing import Self, Any, Sequence, TypeVar -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.ModelAbstract import ModelAbstract -from Utils.Common import Common -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.ModelAbstract import ModelAbstract +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check T = TypeVar("T", bound = ModelAbstract) diff --git a/Python/Managers/PrintTypesManager.py b/Python/AnP/Managers/PrintTypesManager.py similarity index 93% rename from Python/Managers/PrintTypesManager.py rename to Python/AnP/Managers/PrintTypesManager.py index 8733d93..23e3cc9 100644 --- a/Python/Managers/PrintTypesManager.py +++ b/Python/AnP/Managers/PrintTypesManager.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- from typing import Any, Self, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Common import Common -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check class PrintTypesManager: diff --git a/Python/Managers/PseudoLoRAsManager.py b/Python/AnP/Managers/PseudoLoRAsManager.py similarity index 96% rename from Python/Managers/PseudoLoRAsManager.py rename to Python/AnP/Managers/PseudoLoRAsManager.py index cac30c1..3a9b863 100644 --- a/Python/Managers/PseudoLoRAsManager.py +++ b/Python/AnP/Managers/PseudoLoRAsManager.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- from typing import Self, Any, Sequence, Callable, Optional -from Interfaces.Application.AnPInterface import AnPInterface -from Models.PseudoLoRAModel import PseudoLoRAModel -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Models.PseudoLoRAModel import PseudoLoRAModel +from AnP.Utils.Checks import Check class PseudoLoRAsManager: diff --git a/Python/Managers/QueusManager.py b/Python/AnP/Managers/QueusManager.py similarity index 94% rename from Python/Managers/QueusManager.py rename to Python/AnP/Managers/QueusManager.py index 8bfa2a9..838199a 100644 --- a/Python/Managers/QueusManager.py +++ b/Python/AnP/Managers/QueusManager.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- from typing import Self, Any, Callable, Optional, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Models.QueuesModel import QueuesModel -from Utils.Common import Common +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Models.QueuesModel import QueuesModel +from AnP.Utils.Common import Common class QueuesManager: diff --git a/Python/Managers/RoutesManager.py b/Python/AnP/Managers/RoutesManager.py similarity index 94% rename from Python/Managers/RoutesManager.py rename to Python/AnP/Managers/RoutesManager.py index e576962..52fae7a 100644 --- a/Python/Managers/RoutesManager.py +++ b/Python/AnP/Managers/RoutesManager.py @@ -1,13 +1,12 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import re from typing import Self, Any -from Interfaces.Application.AnPInterface import AnPInterface -from Models.RouteModel import RouteModel -from Models.RequestModel import RequestModel -from Utils.Common import Common -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Models.RouteModel import RouteModel +from AnP.Models.RequestModel import RequestModel +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check class RoutesManager: diff --git a/Python/Managers/SessionsManager.py b/Python/AnP/Managers/SessionsManager.py similarity index 94% rename from Python/Managers/SessionsManager.py rename to Python/AnP/Managers/SessionsManager.py index b758e1a..6fce40d 100644 --- a/Python/Managers/SessionsManager.py +++ b/Python/AnP/Managers/SessionsManager.py @@ -4,8 +4,8 @@ from typing import Self, Optional, Any from threading import Thread from time import time as timestamp -from Interfaces.Application.AnPInterface import AnPInterface -from Models.SessionModel import SessionModel +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Models.SessionModel import SessionModel class SessionsManager: diff --git a/Python/Managers/SettingsManager.py b/Python/AnP/Managers/SettingsManager.py similarity index 92% rename from Python/Managers/SettingsManager.py rename to Python/AnP/Managers/SettingsManager.py index c20334f..dc4cadc 100644 --- a/Python/Managers/SettingsManager.py +++ b/Python/AnP/Managers/SettingsManager.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- from typing import Any, Optional, Self, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Common import Common -from Utils.Checks import Check +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check class SettingsManager: diff --git a/Python/Managers/TerminalManager.py b/Python/AnP/Managers/TerminalManager.py similarity index 93% rename from Python/Managers/TerminalManager.py rename to Python/AnP/Managers/TerminalManager.py index 5c3626f..db0dab7 100644 --- a/Python/Managers/TerminalManager.py +++ b/Python/AnP/Managers/TerminalManager.py @@ -1,12 +1,12 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from typing import Self, Callable, Any, Optional +from typing import Self, Any, Optional from threading import Thread -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Checks import Check -from Utils.Common import Common -from Models.CommandModel import CommandModel +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Checks import Check +from AnP.Utils.Common import Common +from AnP.Models.CommandModel import CommandModel class TerminalManager: diff --git a/Python/Managers/UniqueKeysManager.py b/Python/AnP/Managers/UniqueKeysManager.py similarity index 88% rename from Python/Managers/UniqueKeysManager.py rename to Python/AnP/Managers/UniqueKeysManager.py index 9961e9f..caab37b 100644 --- a/Python/Managers/UniqueKeysManager.py +++ b/Python/AnP/Managers/UniqueKeysManager.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from typing import Self, Any -from Interfaces.Application.AnPInterface import AnPInterface -from Utils.Common import Common +from typing import Self +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Utils.Common import Common class UniqueKeysManager: diff --git a/Python/Managers/WebSocketServersManager.py b/Python/AnP/Managers/WebSocketServersManager.py similarity index 93% rename from Python/Managers/WebSocketServersManager.py rename to Python/AnP/Managers/WebSocketServersManager.py index 03c402f..7244dab 100644 --- a/Python/Managers/WebSocketServersManager.py +++ b/Python/AnP/Managers/WebSocketServersManager.py @@ -2,12 +2,12 @@ # -*- coding: utf-8 -*- from typing import Any, Self, Optional, Sequence -from Interfaces.Application.AnPInterface import AnPInterface -from Abstracts.WebSocketServersAbstract import WebSocketServersAbstract -from Application.Event import Event -from Models.RequestModel import RequestModel -from Utils.Checks import Check -from Utils.Common import Common +from AnP.Interfaces.Application.AnPInterface import AnPInterface +from AnP.Abstracts.WebSocketServersAbstract import WebSocketServersAbstract +from AnP.Application.Event import Event +from AnP.Models.RequestModel import RequestModel +from AnP.Utils.Checks import Check +from AnP.Utils.Common import Common class WebSocketServersManager: diff --git a/Python/Managers/__init__py b/Python/AnP/Managers/__init__py similarity index 100% rename from Python/Managers/__init__py rename to Python/AnP/Managers/__init__py diff --git a/Python/Models/AIResponseModel.py b/Python/AnP/Models/AIResponseModel.py similarity index 100% rename from Python/Models/AIResponseModel.py rename to Python/AnP/Models/AIResponseModel.py diff --git a/Python/Models/CommandModel.py b/Python/AnP/Models/CommandModel.py similarity index 88% rename from Python/Models/CommandModel.py rename to Python/AnP/Models/CommandModel.py index 9fa5e77..acb1250 100644 --- a/Python/Models/CommandModel.py +++ b/Python/AnP/Models/CommandModel.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- from typing import Any, Callable, Optional, Self, Sequence -from Utils.Common import Common -from Utils.Checks import Check +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check class CommandModel: diff --git a/Python/AnP/Models/HashModel.py b/Python/AnP/Models/HashModel.py new file mode 100644 index 0000000..bfe25b5 --- /dev/null +++ b/Python/AnP/Models/HashModel.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from hashlib import md5, sha1, sha256, blake2b +from zlib import crc32 +from typing import Self, Protocol +from AnP.Utils.Checks import Check + +class HashAlgorithm(Protocol): + def update(self:Self, data:bytes) -> None: ... + def hexdigest(self:Self) -> str: ... + +class CRC32HashAlgorithm(HashAlgorithm): + + def __init__(self:Self) -> None: + self.__value:int = 0 + + def update(self:Self, data:bytes) -> None: + self.__value = crc32(data, self.__value) + + def hexdigest(self:Self) -> str: + return f"{self.__value & 0xFFFFFFFF:08x}" + +class HashModel(): + + def __init__(self:Self, data:bytes = b"", chunk_size:int = 4096) -> None: + + self.__chunk_size:int = chunk_size + self.md5:str = "" + self.sha1:str = "" + self.sha256:str = "" + self.blake2b:str = "" + self.crc32:str = "" + self.__hashes:list[HashAlgorithm] = ["md5", "sha1", "sha256", "blake2b", "crc32"] + self.__algorithms:list[HashAlgorithm] = [ + method() for method in (md5, sha1, sha256, blake2b, CRC32HashAlgorithm) + ] + + len(data) and self.update(data) + + def __update_chunk(self:Self, chunk:bytes) -> None: + for hash_algorithm in self.__algorithms: + hash_algorithm.update(chunk) + + def update(self:Self, data:bytes|str, encode:str = "utf-8") -> None: + + done:bool = False + + if Check.is_string(data): + data = data.encode(encode) + + if Check.is_binary(data): + + while data: + + chunk:bytes = data[:self.__chunk_size] + + data = data[self.__chunk_size:] + self.__update_chunk(chunk) + + done = True + + if done: + + name:str + + for name in self.__hashes: + setattr(self, name, getattr(self.__algorithms[self.__hashes.index(name)], "hexdigest")()) + + return done + + def compare(self:Self, other:Self) -> bool: + return all(getattr(self, name) == getattr(other, name) for name in self.__hashes) \ No newline at end of file diff --git a/Python/Models/PseudoLoRAModel.py b/Python/AnP/Models/PseudoLoRAModel.py similarity index 90% rename from Python/Models/PseudoLoRAModel.py rename to Python/AnP/Models/PseudoLoRAModel.py index 50164e5..b92e729 100644 --- a/Python/Models/PseudoLoRAModel.py +++ b/Python/AnP/Models/PseudoLoRAModel.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- from typing import Self, Any, Sequence, Optional -from Utils.Checks import Check -from Utils.Common import Common +from AnP.Utils.Checks import Check +from AnP.Utils.Common import Common class PseudoLoRAModel: diff --git a/Python/Models/QueuesModel.py b/Python/AnP/Models/QueuesModel.py similarity index 96% rename from Python/Models/QueuesModel.py rename to Python/AnP/Models/QueuesModel.py index 864c0da..9daf4aa 100644 --- a/Python/Models/QueuesModel.py +++ b/Python/AnP/Models/QueuesModel.py @@ -3,8 +3,8 @@ from typing import Self, Any, Callable, Sequence, Optional from threading import Thread, Lock -from Utils.Checks import Check -from Utils.Common import Common +from AnP.Utils.Checks import Check +from AnP.Utils.Common import Common class QueueItemModel: def __init__(self:Self, i:int, callback:Callable[[Callable[[], None]], None], *arguments:list[Any|None]) -> None: diff --git a/Python/Models/RequestModel.py b/Python/AnP/Models/RequestModel.py similarity index 95% rename from Python/Models/RequestModel.py rename to Python/AnP/Models/RequestModel.py index 62682c2..f4277d7 100644 --- a/Python/Models/RequestModel.py +++ b/Python/AnP/Models/RequestModel.py @@ -3,9 +3,9 @@ from typing import Any, Self, Callable, Sequence, Optional from json import dumps as json_encode -from Models.SessionModel import SessionModel -from Abstracts.RouteAbstract import RouteAbstract -from Utils.Common import Common +from AnP.Models.SessionModel import SessionModel +from AnP.Abstracts.RouteAbstract import RouteAbstract +from AnP.Utils.Common import Common class RequestModel: diff --git a/Python/Models/RouteModel.py b/Python/AnP/Models/RouteModel.py similarity index 95% rename from Python/Models/RouteModel.py rename to Python/AnP/Models/RouteModel.py index dcde5dd..0e09a90 100644 --- a/Python/Models/RouteModel.py +++ b/Python/AnP/Models/RouteModel.py @@ -3,11 +3,11 @@ from typing import Self, Any, Sequence, Callable from re import Match as REMatch, Pattern as REPattern, compile as re_compile -from Abstracts.RouteAbstract import RouteAbstract -from Utils.Common import Common -from Utils.Checks import Check -from Utils.Patterns import RE -from Models.RequestModel import RequestModel +from AnP.Abstracts.RouteAbstract import RouteAbstract +from AnP.Utils.Common import Common +from AnP.Utils.Checks import Check +from AnP.Utils.Patterns import RE +from AnP.Models.RequestModel import RequestModel class RouteModel(RouteAbstract): diff --git a/Python/Models/SessionModel.py b/Python/AnP/Models/SessionModel.py similarity index 100% rename from Python/Models/SessionModel.py rename to Python/AnP/Models/SessionModel.py diff --git a/Python/Models/__init__py b/Python/AnP/Models/__init__py similarity index 100% rename from Python/Models/__init__py rename to Python/AnP/Models/__init__py diff --git a/Python/Utils/Checks.py b/Python/AnP/Utils/Checks.py similarity index 94% rename from Python/Utils/Checks.py rename to Python/AnP/Utils/Checks.py index 49b7325..1ce6fe0 100644 --- a/Python/Utils/Checks.py +++ b/Python/AnP/Utils/Checks.py @@ -5,7 +5,7 @@ from typing import Any, Self, Sequence from re import Pattern as REPattern from os.path import isfile as is_file from json import loads as json_decode -from Utils.Patterns import RE +from AnP.Utils.Patterns import RE class Check: @@ -74,7 +74,7 @@ class Check: mark:str - for mark in cls.get_keys(marks): + for mark in marks if Check.is_array(marks) else (marks,): if key.startswith(mark + "_") and ( key.endswith("_start") or key.endswith("_end") diff --git a/Python/Utils/Common.py b/Python/AnP/Utils/Common.py similarity index 99% rename from Python/Utils/Common.py rename to Python/AnP/Utils/Common.py index d0e6211..8e5ad60 100644 --- a/Python/Utils/Common.py +++ b/Python/AnP/Utils/Common.py @@ -11,8 +11,8 @@ from inspect import FrameInfo, stack as get_stack from json import dumps as json_encode, loads as json_decode from base64 import b64encode as base64_encode, b64decode as base64_decode from random import choice as random_choice -from Utils.Checks import Check -from Utils.Patterns import RE +from AnP.Utils.Checks import Check +from AnP.Utils.Patterns import RE ROOT_PATH:str = absolute_path(directory_name(__file__)) SLASH:str = "/" if "/" in ROOT_PATH else "\\\\" diff --git a/Python/Utils/Patterns.py b/Python/AnP/Utils/Patterns.py similarity index 100% rename from Python/Utils/Patterns.py rename to Python/AnP/Utils/Patterns.py diff --git a/Python/Utils/__init__py b/Python/AnP/Utils/__init__py similarity index 100% rename from Python/Utils/__init__py rename to Python/AnP/Utils/__init__py diff --git a/Python/AnP/__init__.py b/Python/AnP/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Python/base.py b/Python/base.py new file mode 100644 index 0000000..8337c0c --- /dev/null +++ b/Python/base.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from typing import Any +from AnP.Controllers.AIController import AIController +from AnP.Drivers.WebSocketServerDriver import WebSocketServerDriver +from AnP.Drivers.HTTPSocketServerDriver import HTTPSocketServerDriver +from AnP.Drivers.HTTPServerDriver import HTTPServerDriver +from AnP.Drivers.OllamaDriver import OllamaDriver +from AnP.Drivers.FilesDriver import FilesDriver +from AnP.Controllers.CloneController import CloneController +from AnP.Controllers.AITranslateController import AITranslateController + +inputs:dict[str, dict[str, Any|None]] = { + "default_models" : { + "AIController" : AIController, + "CloneController" : CloneController, + "AITranslateController" : AITranslateController, + "WebSocketServerDriver" : WebSocketServerDriver, + "HTTPSocketServerDriver" : HTTPSocketServerDriver, + "HTTPServerDriver" : HTTPServerDriver, + "OllamaDriver" : OllamaDriver, + "FilesDriver" : FilesDriver + } +} + +try: + + from secrets import secrets as custom_secrets + + for key, value in dict(custom_secrets).items(): + if key not in inputs or isinstance(inputs[key], dict): + inputs[key] = value + elif isinstance(value, dict): + for subkey, subvalue in value.items(): + inputs[key][subkey] = subvalue + +except ImportError: + pass \ No newline at end of file diff --git a/Python/map.anp.py b/Python/map.anp.py deleted file mode 100644 index 4b52553..0000000 --- a/Python/map.anp.py +++ /dev/null @@ -1,312 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from abc import ABC, abstractmethod -from typing import Any, Callable, Self, Sequence, Optional, ClassVar -from re import Pattern as REPattern -from threading import Thread - -class RE: - - KEY:ClassVar[REPattern] - STRING_VARIABLES:ClassVar[REPattern] - SLASHES:ClassVar[REPattern] - NEW_LINES:ClassVar[REPattern] - ROUTE:ClassVar[REPattern] - TO_REGULAR_EXPRESSION:ClassVar[REPattern] - ROUTE_KEY:ClassVar[REPattern] - EXCEPTION:ClassVar[REPattern] - NEW_LINE:ClassVar[REPattern] - HTTP_VARIABLE:ClassVar[REPattern] - PARENT_PATH:ClassVar[REPattern] - DOUBLE_NEW_LINE:ClassVar[REPattern] - HTTP_HEADER_PARAMETER:ClassVar[REPattern] - HTTP_REQUEST:ClassVar[REPattern] - -class Check(ABC): - - @staticmethod - @abstractmethod - def is_string(item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_binary(item:Any|None) -> bool:pass - - @classmethod - @abstractmethod - def is_key(cls:type[Self], item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_array(item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_dictionary(item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_boolean(item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_integer(item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_function(item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_regular_expression(item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_json_string(item:Any|None, full:bool = False) -> bool:pass - - @staticmethod - @abstractmethod - def is_json(item:Any|None) -> bool:pass - - @staticmethod - @abstractmethod - def is_json_data(item:Any|None, full:bool = False) -> bool:pass - - @classmethod - @abstractmethod - def is_mark_key(cls:type[Self], key:str, marks:str|Sequence[str] = "AnP") -> bool:pass - - @staticmethod - @abstractmethod - def is_file(path:str) -> bool:pass - -class Common(ABC): - - ROOT_PATH:ClassVar[str] - SLASH:ClassVar[str] - ROOTS_PATH:ClassVar[list[str]] - SPECIAL_REGULAR_EXPRESSION_CHARACTERS:ClassVar[dict[str, str]] - - @classmethod - @abstractmethod - def get_keys(cls:type[Self], *items:list[Any|None]) -> list[str]:pass - - @classmethod - @abstractmethod - def get_texts(cls:type[Self], *items:list[Any|None]) -> list[str]:pass - - @classmethod - @abstractmethod - def get_dictionaries(cls:type[Self], *items:list[Any|None]) -> list[dict[str, Any|None]]:pass - - @classmethod - @abstractmethod - def get_dictionary(cls:type[Self], inputs:Any|None, overwrite:bool = False) -> dict[str, Any|None]:pass - - @classmethod - @abstractmethod - def get_value(cls:type[Self], - keys:str|Sequence[str], - inputs:dict[str, Any|None]|Sequence[Any|None], - default:Optional[Any|None] = None - ) -> Any|None:pass - - @classmethod - @abstractmethod - def string_variables(cls:type[Self], - string:str, - inputs:dict[str, Any|None]|Sequence[Any|None], - default:Optional[str] = None - ) -> str:pass - - @classmethod - @abstractmethod - def fix_path(cls:type[Self], path:str) -> str:pass - - @classmethod - @abstractmethod - def get_absolute_path(cls:type[Self], path:str) -> str|None:pass - - @classmethod - @abstractmethod - def load_file(cls:type[Self], path:str, mode:str = "r") -> str|bytes|None:pass - - @classmethod - @abstractmethod - def load_json(cls:type[Self], - data:str|dict[str, Any|None]|Sequence[Any|None], - only_dictionaries:bool = True - ) -> list[dict[str, Any|None]|Sequence[Any|None]]:pass - - @staticmethod - @abstractmethod - def get_action_data(i:int = 0) -> dict[str, str|int]:pass - - @classmethod - @abstractmethod - def to_regular_expression(cls:type[Self], string:str) -> str:pass - - @staticmethod - @abstractmethod - def get_mime_from_path(path:str) -> str|None:pass - - @staticmethod - @abstractmethod - def json_encode(data:dict[str, Any|None]|Sequence[Any|None]) -> str|None:pass - - @staticmethod - @abstractmethod - def json_decode(data:str|bytes) -> dict[str, Any|None]|Sequence[Any|None]|None:pass - - @staticmethod - @abstractmethod - def base64_encode(data:bytes) -> str|None:pass - - @staticmethod - @abstractmethod - def base64_decode(data:str) -> bytes|None:pass - - @classmethod - @abstractmethod - def data_encode(cls:type[Self], data:Any|None) -> str|None:pass - - @classmethod - @abstractmethod - def data_decode(cls:type[Self], data:str) -> Any|None:pass - - @staticmethod - @abstractmethod - def execute(callback:Callable[..., Any|None], *arguments:Any|None) -> Any|None:pass - - @staticmethod - @abstractmethod - def unique(items:str|Sequence[Any|None]) -> str|list[Any|None]:pass - - @staticmethod - @abstractmethod - def random(items:str|Sequence[Any|None]) -> Any|None:pass - -class AIResponseModel(ABC): - - def __init__(self:Self, conversation:str) -> None: - self.conversation:str - self.start:float - self.model:str - self.response:str - self.total:str - self.context:str|list[str] - self.done:bool - self.end:float|None - self.chunks:int - self.ok:bool - self.http_code:int - self.http_message:str - - @abstractmethod - def update(self:Self, data:dict[str, Any|None]) -> None:pass - -class CommandModel(ABC): - - def __init__(self:Self, - names:str|Sequence[str], - callback:Callable[[dict[str, Any|None], Optional[list[Any|None]]], None] - ) -> None: - self.names:list[str] - self.callback:Callable[[dict[str, Any|None], Optional[list[Any|None]]], None] - - @abstractmethod - def update(self:Self, - names:str|Sequence[str], - callback:Optional[Callable[[dict[str, Any|None], Optional[list[Any|None]]], None]] = None, - overwrite:bool = False - ) -> None:pass - -class PseudoLoRAModel(ABC): - - def __init__(self:Self, - title:str, - content:str|Sequence[Any|None], - keys:Optional[str|Sequence[str]] = None, - cacheable:bool = False - ) -> None: - self.title:str - self.path:str|None - self.memory:int - self.cache:str - self.i:int - self.keys:list[str] - self.cacheable:bool - self.nested:list[PseudoLoRAModel] - - @abstractmethod - def clean_cache(self:Self) -> None:pass - -class QueueItemModel(ABC): - def __init__(self:Self, i:int, callback:Callable[[Callable[[], None]], None], *arguments:list[Any|None]) -> None: - self.i:int - self.callback:Callable[[Callable[[], None]], None] - self.arguments:list[Any|None] - self.executing:bool - self.thread:Thread|None - -class QueuesModel(ABC): - - def __init__(self:Self, key:str, inputs:Optional[int|dict[str, Any|None]|Sequence[Any|None]] = None) -> None: - self.key:str - self.items:dict[int, QueueItemModel] - self.i:int - self.p:int - self.maximum:int - self.current:int - - @abstractmethod - def add(self:Self, callback:Callable[[Callable[[], None]], None], *arguments:list[Any|None]) -> int|None:pass - - @abstractmethod - def cancel(self:Self, i:int) -> bool:pass - - @abstractmethod - def cancel_all(self:Self) -> None:pass - - @abstractmethod - def next(self:Self) -> None:pass - -class RequestModel(ABC): - - def __init__(self:Self, session:Optional[SessionModel] = None) -> None: - self.post_variables:dict[str, Any|None] - self.get_variables:dict[str, Any|None] - self.url_variables:dict[str, Any|None] - self.hash_variables:dict[str, Any|None] - self.cookies:dict[str, Any|None] - self.variables:dict[str, Any|None] - self.request_headers:dict[str, Any|None] - self.method:str|None - self.route:RouteAbstract|None - self.response:str|bytes|None - self.response_mime:str|None - self.response_charset:str|None - self.response_code:int - self.response_headers:dict[str, Any|None] - self.callback:Callable[[RequestModel, str|bytes|None], None]|None - self.data:Any|None - self.session:SessionModel|None - self.protocol:str|None - self.protocol_version:str|None - self.last_modified:str|None - - @abstractmethod - def get(self:Self, key:str|Sequence[str], default:Optional[Any] = None) -> Any|None:pass - - @abstractmethod - def set_variables(self:Self, inputs:dict[str, Any|None], on:Optional[str] = None) -> None:pass - - @abstractmethod - def set_response(self:Self, data:Any|None) -> None:pass - - @abstractmethod - def set_request_headers(self:Self, inputs:Any|None) -> None:pass - - @abstractmethod - def set_response_headers(self:Self, inputs:Any|None) -> None:pass \ No newline at end of file diff --git a/Python/run.py b/Python/run.py index 477d4d5..2b1ec1f 100644 --- a/Python/run.py +++ b/Python/run.py @@ -1,38 +1,9 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from typing import Any -from Application.AnP import AnP -from Controllers.AIController import AIController -from Drivers.WebSocketServerDriver import WebSocketServerDriver -from Drivers.HTTPSocketServerDriver import HTTPSocketServerDriver -from Drivers.HTTPServerDriver import HTTPServerDriver -from Drivers.OllamaDriver import OllamaDriver -from Drivers.FilesDriver import FilesDriver +from AnP.Application.AnP import AnP +from base import inputs -inputs:dict[str, dict[str, Any|None]] = { - "default_models" : { - "AIController" : AIController, - "WebSocketServerDriver" : WebSocketServerDriver, - "HTTPSocketServerDriver" : HTTPSocketServerDriver, - "HTTPServerDriver" : HTTPServerDriver, - "OllamaDriver" : OllamaDriver, - "FilesDriver" : FilesDriver - } -} +anp:AnP = AnP(inputs) -try: - - from secrets import secrets as custom_secrets - - for key, value in dict(custom_secrets).items(): - if key not in inputs or isinstance(inputs[key], dict): - inputs[key] = value - elif isinstance(value, dict): - for subkey, subvalue in value.items(): - inputs[key][subkey] = subvalue - -except ImportError: - pass - -anp:AnP = AnP(inputs) \ No newline at end of file +anp.controllers.execute("clonations_processes", "execute", None) \ No newline at end of file