Skip to content
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

fix: formulation template name #132

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions questionpy_sdk/commands/create.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is part of the QuestionPy SDK. (https://questionpy.org)
# The QuestionPy SDK is free software released under terms of the MIT license. See LICENSE.md.
# (c) Technische Universität Berlin, innoCampus <info@isis.tu-berlin.de>

from fileinput import FileInput
from pathlib import Path
from zipfile import ZipFile

Expand Down Expand Up @@ -49,7 +49,16 @@ def create(short_name: str, namespace: str, out_path: Path | None) -> None:
# Rename namespaced python folder.
python_folder = out_path / "python"
namespace_folder = (python_folder / "local").rename(python_folder / namespace)
(namespace_folder / "minimal_example").rename(namespace_folder / short_name)
short_name_folder = (namespace_folder / "minimal_example").rename(namespace_folder / short_name)

# Rename template name.
with FileInput(short_name_folder / "question_type.py", inplace=True) as file:
for line in file:
if file.filelineno() == 20: # noqa: PLR2004
Copy link
Contributor

@tumidi tumidi Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die Zeilennr. hardcoden kann's irgendwie nicht sein. Das geht kaputt sobald jemand die Datei question_type.py mal anfassen muss.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sehe ich auch so.

new_line = line.replace("local.minimal_example", f"{namespace}.{short_name}", 1)
else:
new_line = line
print(new_line, end="") # noqa: T201

config_path = out_path / PACKAGE_CONFIG_FILENAME

Expand Down