Skip to content

Commit 3496919

Browse files
committed
[new_problem] Correctly read source from args.contest
Related to RagnarGrootKoerkamp#166: this bug existed because new_problem did not change directory to args.contest.
1 parent 3d8c04d commit 3496919

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bin/skel.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def get_skel_dir(target_dir):
131131
def new_problem():
132132
target_dir = Path(".")
133133
if config.args.contest:
134-
target_dir = Path(config.args.contest)
134+
os.chdir(Path(config.args.contest))
135135
if config.args.problem:
136136
fatal("--problem does not work for new_problem.")
137137

@@ -186,12 +186,14 @@ def new_problem():
186186
}.items():
187187
variables[k] = v
188188

189-
variables["source"] = _ask_variable_string(
189+
source_name = _ask_variable_string(
190190
"source", variables.get("source", variables.get("name", "")), True
191191
)
192-
variables["source_url"] = _ask_variable_string(
193-
"source url", variables.get("source_url", ""), True
192+
source_url = _ask_variable_string("source url", variables.get("source_url", ""), True)
193+
variables["source"] = (
194+
f"source:\n name: {source_name}\n{' url: {source_url}' if source_url else ' #url:'}"
194195
)
196+
195197
variables["license"] = _ask_variable_choice(
196198
"license", config.KNOWN_LICENSES, variables.get("license", None)
197199
)

skel/problem/problem.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ name:
77
{%problemname%}
88
uuid: {%uuid%}
99
credits: {%author%}
10-
source:
11-
name: {%source%}
12-
url: {%source_url%}
10+
{%source%}
1311
license: {%license%}
1412
rights_owner: {%rights_owner%}
1513

0 commit comments

Comments
 (0)