From ac82b0a78b27efaaec029a3eec70e00f9528d241 Mon Sep 17 00:00:00 2001 From: KyMAN <0kyman0@gmail.com> Date: Sat, 4 May 2024 11:13:39 +0200 Subject: [PATCH] #wip(py): Errors in base64 done. --- Python/Application/MemWeb.Terminal.py | 2 +- Python/Application/MemWeb.py | 11 ++++++++++- version | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Python/Application/MemWeb.Terminal.py b/Python/Application/MemWeb.Terminal.py index c1597da..6deb590 100644 --- a/Python/Application/MemWeb.Terminal.py +++ b/Python/Application/MemWeb.Terminal.py @@ -242,7 +242,7 @@ class Anonymous(MemWeb.Abstracts.Common): data[processed_key] = self.__get_method(data, subkey) error |= ( - (1 << 0 if i else 0) if data[processed_key] == None else + (0 if i else 1 << 0) if data[processed_key] == None else 1 << 1 if not callable(data[processed_key]) else 0) << (38 + i * 2) diff --git a/Python/Application/MemWeb.py b/Python/Application/MemWeb.py index c79466f..29da9fd 100644 --- a/Python/Application/MemWeb.py +++ b/Python/Application/MemWeb.py @@ -10,6 +10,7 @@ from inspect import stack as get_stack from traceback import format_stack as trace_format_stack from traceback import extract_tb as extract_traceback from time import time as timestamp +from base64 import b64encode as base64_encode import datetime if "common" not in globals(): @@ -529,6 +530,13 @@ class MemWeb: "method" : stack.function, "line" : stack.lineno } + + @staticmethod + def base64_encode(data): + return base64_encode(bytes( + data.to_bytes((data.bit_length() + 7) // 8, byteorder = "big") if isinstance(data, (int, float)) else + data.encode() if isinstance(data, str) else + data.encode("ascii"))).decode() def _print(self, _type, message, inputs = None, i = 1): @@ -738,7 +746,8 @@ class MemWeb: if error_message: own = { - "code" : error, + "code" : self.base64_encode(error), + "raw_code" : error, "end" : "", **{key : value for subset in (variables if isinstance(variables, (list, tuple)) else (variables,)) for key, value in (subset if isinstance(subset, dict) else {}).items()} } diff --git a/version b/version index 6812f81..05b19b1 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.0.3 \ No newline at end of file +0.0.4 \ No newline at end of file