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:
parent
88bd156316
commit
0ee34076df
3 changed files with 0 additions and 11 deletions
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import ast
|
|
||||||
import tokenize
|
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -25,7 +23,6 @@ def main():
|
||||||
|
|
||||||
if args.file:
|
if args.file:
|
||||||
script_path = pathlib.Path(args.file).absolute()
|
script_path = pathlib.Path(args.file).absolute()
|
||||||
script_dir = script_path.parent
|
|
||||||
|
|
||||||
# Read and transpile the German code
|
# Read and transpile the German code
|
||||||
with open(script_path) as f:
|
with open(script_path) as f:
|
||||||
|
|
|
@ -32,7 +32,6 @@ class DeuthonSourceLoader(importlib.machinery.SourceFileLoader):
|
||||||
def source_to_code(self, data, path, *, _optimize=-1):
|
def source_to_code(self, data, path, *, _optimize=-1):
|
||||||
reader = tokenize.open(path)
|
reader = tokenize.open(path)
|
||||||
try:
|
try:
|
||||||
encoding = reader.encoding
|
|
||||||
source_data = reader.read()
|
source_data = reader.read()
|
||||||
finally:
|
finally:
|
||||||
reader.close()
|
reader.close()
|
||||||
|
@ -122,12 +121,6 @@ class DeuthonModuleFinder(importlib.abc.MetaPathFinder):
|
||||||
if deuthon_path:
|
if deuthon_path:
|
||||||
path.extend(deuthon_path.split(os.pathsep))
|
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:
|
for entry in path:
|
||||||
module_full_path = os.path.join(
|
module_full_path = os.path.join(
|
||||||
entry, fullname.replace(".", "/") + self.extension
|
entry, fullname.replace(".", "/") + self.extension
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import ast
|
|
||||||
import tokenize
|
import tokenize
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
Loading…
Reference in a new issue