Skip to content

Commit a277b6f

Browse files
committed
style: apply ruff formatting to init.py and cli.py
1 parent a3a2b0c commit a277b6f

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

concore_cli/commands/init.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
from xml.sax.saxutils import quoteattr
23
from rich.panel import Panel
34

45
from .metadata import write_study_metadata
@@ -14,7 +15,7 @@
1415
xmlns:y="http://www.yworks.com/xml/graphml">
1516
<key for="node" id="d6" yfiles.type="nodegraphics"/>
1617
<key for="edge" id="d10" yfiles.type="edgegraphics"/>
17-
<graph edgedefault="directed" id="1">
18+
<graph edgedefault="directed" id="1" projectName={project_name}>
1819
{nodes}
1920
</graph>
2021
</graphml>
@@ -245,7 +246,7 @@ def _build_graphml(project_name, selected_langs):
245246
)
246247
)
247248
return GRAPHML_HEADER.format(
248-
project_name=project_name,
249+
project_name=quoteattr(project_name),
249250
nodes="\n".join(node_blocks),
250251
)
251252

@@ -270,6 +271,11 @@ def init_project_interactive(name, selected_langs, console):
270271
console.print(f"[cyan]Creating project:[/cyan] {name}")
271272

272273
project_path.mkdir()
274+
src_path = project_path / "src"
275+
src_path.mkdir()
276+
277+
# workflow.graphml
278+
workflow_file = project_path / "workflow.graphml"
273279
workflow_file.write_text(_build_graphml(name, selected_langs), encoding="utf-8")
274280

275281
# one source stub per selected language
@@ -279,12 +285,8 @@ def init_project_interactive(name, selected_langs, console):
279285

280286
# README
281287
(project_path / "README.md").write_text(
282-
README_TEMPLATE.format(project_name=name),
283-
encoding="utf-8",
284-
(src_path / info["filename"]).write_text(info["stub"])
285-
286-
# README
287-
(project_path / "README.md").write_text(README_TEMPLATE.format(project_name=name))
288+
README_TEMPLATE.format(project_name=name), encoding="utf-8"
289+
)
288290

289291
# Metadata
290292
metadata_info = ""
@@ -334,12 +336,16 @@ def init_project(name, template, console):
334336
(project_path / "src").mkdir()
335337

336338
workflow_file = project_path / "workflow.graphml"
337-
with open(workflow_file, "w") as f:
339+
with open(workflow_file, "w", encoding="utf-8") as f:
338340
f.write(SAMPLE_GRAPHML)
339341

340-
(project_path / "src" / "script.py").write_text(LANGUAGE_NODES["python"]["stub"])
342+
(project_path / "src" / "script.py").write_text(
343+
LANGUAGE_NODES["python"]["stub"], encoding="utf-8"
344+
)
341345

342-
(project_path / "README.md").write_text(README_TEMPLATE.format(project_name=name))
346+
(project_path / "README.md").write_text(
347+
README_TEMPLATE.format(project_name=name), encoding="utf-8"
348+
)
343349

344350
metadata_info = ""
345351
try:

0 commit comments

Comments
 (0)