feat: optimize imports and streamline processing

Removed unused imports across various modules, streamlining the codebase by eliminating the `ast` and `tokenize` modules where not directly utilized. This clean-up not only simplifies the code making it more maintainable but also potentially improves runtime performance by reducing overhead. Additionally, redundant variables and comments that do not contribute to clarity or functionality, such as `script_dir` and detailed notes on module path construction, were pruned to further enhance code readability and efficiency.

This change underscores our commitment to maintaining a lean and efficient codebase, facilitating easier updates and modifications in the future.
This commit is contained in:
Kumi 2024-05-26 21:03:59 +02:00
parent 88bd156316
commit 0ee34076df
Signed by: kumi
GPG key ID: ECBCC9082395383F
3 changed files with 0 additions and 11 deletions

View file

@ -1,7 +1,5 @@
#!/usr/bin/env python3
import ast
import tokenize
import pathlib
import sys
import traceback
@ -25,7 +23,6 @@ def main():
if args.file:
script_path = pathlib.Path(args.file).absolute()
script_dir = script_path.parent
# Read and transpile the German code
with open(script_path) as f:

View file

@ -32,7 +32,6 @@ class DeuthonSourceLoader(importlib.machinery.SourceFileLoader):
def source_to_code(self, data, path, *, _optimize=-1):
reader = tokenize.open(path)
try:
encoding = reader.encoding
source_data = reader.read()
finally:
reader.close()
@ -122,12 +121,6 @@ class DeuthonModuleFinder(importlib.abc.MetaPathFinder):
if deuthon_path:
path.extend(deuthon_path.split(os.pathsep))
# The base name for the file we're trying to find will be the last component of 'fullname'
# e.g., for 'testmodul.submodul.test', we want to end up with 'test.deu'
module_basename = (
fullname.rpartition(".")[-1] + self.extension
) # e.g., 'test.deu'
for entry in path:
module_full_path = os.path.join(
entry, fullname.replace(".", "/") + self.extension

View file

@ -1,4 +1,3 @@
import ast
import tokenize
from io import BytesIO