From f61f72cb1bfa41a2ce5898a4577fde08b8eb2150 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sun, 14 Jan 2024 21:43:26 +0100 Subject: [PATCH] Cleanup and standardize string delimiters Removed unused imports in dictionary initialization and standardized quote usage for string literals in the transformer module. These changes promote code consistency and reduce clutter, making the codebase cleaner and more maintainable. Additionally, includes minor formatting improvements for readability. --- src/deuthon/dictionary/__init__.py | 3 --- src/deuthon/transformer.py | 9 ++++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/deuthon/dictionary/__init__.py b/src/deuthon/dictionary/__init__.py index 1ee40bc..c26faac 100644 --- a/src/deuthon/dictionary/__init__.py +++ b/src/deuthon/dictionary/__init__.py @@ -1,6 +1,3 @@ -from pathlib import Path -import importlib - dictionary = { # Conditionals "wenn": "if", diff --git a/src/deuthon/transformer.py b/src/deuthon/transformer.py index be94f3f..2762066 100644 --- a/src/deuthon/transformer.py +++ b/src/deuthon/transformer.py @@ -5,6 +5,7 @@ from io import BytesIO from .dictionary import dictionary + def translate_german_keywords(tokens): for token in tokens: # Translate German keywords to English @@ -13,9 +14,10 @@ def translate_german_keywords(tokens): else: yield token + def parse_german_code(german_code): # Convert the German code into bytes for tokenization - bytes_code = bytes(german_code, 'utf-8') + bytes_code = bytes(german_code, "utf-8") # Tokenize the German code tokens = tokenize.tokenize(BytesIO(bytes_code).readline) @@ -24,14 +26,15 @@ def parse_german_code(german_code): english_tokens = translate_german_keywords(tokens) # Detokenize back to a code string in English/Python - python_code_str = tokenize.untokenize(english_tokens).decode('utf-8') + python_code_str = tokenize.untokenize(english_tokens).decode("utf-8") # Return the compiled Python code object return python_code_str + def prepare_builtin_overrides(): import sys original_json = sys.modules["json"] sys.modules["sysjson"] = original_json - del sys.modules["json"] \ No newline at end of file + del sys.modules["json"]