-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minor fixes for ibims orm creation #99
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Der Python-Generator sollte nicht auf das ibims Repo zugeschnitten sein. Versuch stattdessen relative Pfade zu verwenden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ich denke, das passt so für mich, solang es funzt ^^ Aber schau mal, ob man die eine Funktion da noch braucht..
src/bo4e_generator/sqlparser.py
Outdated
# python_code = format_code(python_code) | ||
return python_code | ||
|
||
|
||
def format_code(code: str) -> str: | ||
""" | ||
perform isort and black on code | ||
""" | ||
code = remove_unused_imports(code) | ||
code = black.format_str(code, mode=black.Mode()) | ||
return isort.code(code, known_local_folder=["borm"]) | ||
return isort.code(code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wird format_code
jetzt überhaupt noch verwendet? remove_unused_imports
rufst du ja jetzt auch in generate_bo4e_schemas
auf und mittlerweile sollte das Formatieren auch korrekt funktionieren, meine ich..
src/bo4e_generator/sqlparser.py
Outdated
def remove_unused_imports(code): | ||
""" | ||
Removes unused imports from the given code using autoflake. | ||
""" | ||
# Create a temporary file | ||
with tempfile.NamedTemporaryFile(suffix=".py", delete=False) as tmp_file: | ||
tmp_file_name = tmp_file.name | ||
tmp_file.write(code.encode("utf-8")) | ||
|
||
# Run autoflake to remove unused imports | ||
subprocess.run(["autoflake", "--remove-all-unused-imports", "--in-place", tmp_file_name], check=True) | ||
|
||
# Read the cleaned code from the temporary file | ||
with open(tmp_file_name, "r", encoding="utf-8") as tmp_file: | ||
cleaned_code = tmp_file.read() | ||
|
||
# Clean up the temporary file | ||
os.remove(tmp_file_name) | ||
|
||
return cleaned_code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schick 😊
not only small changes anymore...