Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed Mar 28, 2024
1 parent 04684ec commit 41cf234
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/create_python_cmd/createapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@
def check_name(app_name: str) -> None:
"""Check the name of the application."""
if not app_name.isidentifier():
raise ValueError(
"The name of the application is not a valid Python identifier."
)
raise ValueError("The name of the application is not a valid Python identifier.")


def check_semantic_version(version: str) -> None:
"""Check the version of the application."""
version_list = version.split(".")
for v in version_list:
if not v.isnumeric():
raise ValueError(
"The version of the application is not a valid semantic version."
)
raise ValueError("The version of the application is not a valid semantic version.")


def remove_double_blank_lines(lines: list) -> list:
Expand Down Expand Up @@ -72,9 +68,7 @@ def do_create_python_app(
for root, dirs, files in os.walk(tmpdir):
for d in dirs:
if d == "template-python-cmd" or d == "template_python_cmd":
shutil.move(
os.path.join(root, d), os.path.join(root, app_name_underscore)
)
shutil.move(os.path.join(root, d), os.path.join(root, app_name_underscore))
pyproject = os.path.join(tmpdir, "pyproject.toml")
with open(pyproject, encoding="utf-8", mode="r") as pyproject_file:
pyproject_lines = pyproject_file.read().splitlines()
Expand All @@ -94,9 +88,7 @@ def do_create_python_app(
pyproject_lines[i] = ""
else:
if line.startswith("test_cmd ="):
pyproject_lines[i] = (
f'{command_name} = "{app_name_underscore}.cli:main"'
)
pyproject_lines[i] = f'{command_name} = "{app_name_underscore}.cli:main"'
########
# Transform pyproject file with the new information
pyproject_lines = remove_double_blank_lines(pyproject_lines)
Expand All @@ -108,7 +100,7 @@ def do_create_python_app(
with open(test_cli, encoding="utf-8", mode="r") as test_file:
test_lines = test_file.read().splitlines()
for i, line in enumerate(test_lines):
if line.startswith('COMMAND = "test_cmd"'):
if line.startswith("COMMAND = "):
new_line = f'COMMAND = "{command_name}"'
test_lines[i] = new_line
with open(test_cli, encoding="utf-8", mode="w") as test_file:
Expand Down

0 comments on commit 41cf234

Please sign in to comment.