Skip to content

Commit 8d9e7a4

Browse files
Haruki Kitagawakyuridenamida
authored andcommitted
Make example input / output names configurable from EtcConfig (kyuridenamida#140) (kyuridenamida#141)
* Add in_ and out_example_format to EtcConfig (kyuridenamida#140) envgen.pyにおいてIN_EXAMPLE_FORMAT, OUT_EXAMPLE_FORMATとして定義されていたテストケースのフォーマットを configファイルで設定できるように変更. * Remove redundant spaces from default.toml * Update test_envgen and Rename test cases under resources/test_atc_env/ (kyuridenamida#140) - test_parepare_workspace.tomlにin_example_formatなどを追加 - resources/test_atc_env/*/以下のin_1.txtなどを全て設定に沿ったものに変更 - test_envgen.py::TestEnvGen::test_backupのConfigにEtcConfigを追加 * Update README (kyuridenamida#140)
1 parent ffc7eae commit 8d9e7a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+47
-33
lines changed

README.md

Lines changed: 4 additions & 0 deletions

atcodertools/config/etc_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ def __init__(self,
44
download_without_login: str = False,
55
parallel_download: bool = False,
66
save_no_session_cache: bool = False,
7+
in_example_format: str = "in_{}.txt",
8+
out_example_format: str = "out_{}.txt",
79
):
810
self.download_without_login = download_without_login
911
self.parallel_download = parallel_download
1012
self.save_no_session_cache = save_no_session_cache
13+
self.in_example_format = in_example_format
14+
self.out_example_format = out_example_format

atcodertools/tools/atcodertools-default.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ lang = 'cpp' # 'cpp' or 'java' (Currently)
2525
[etc]
2626
download_without_login=false
2727
parallel_download=false
28-
save_no_session_cache=false
28+
save_no_session_cache=false
29+
in_example_format="in_{}.txt"
30+
out_example_format="out_{}.txt"

atcodertools/tools/envgen.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ class BannedFileDetectedError(Exception):
3737
pass
3838

3939

40-
IN_EXAMPLE_FORMAT = "in_{}.txt"
41-
OUT_EXAMPLE_FORMAT = "out_{}.txt"
42-
43-
4440
def output_splitter():
4541
# for readability
4642
print("=================================================", file=sys.stderr)
@@ -90,7 +86,7 @@ def emit_info(text):
9086
else:
9187
os.makedirs(problem_dir_path, exist_ok=True)
9288
create_examples(content.get_samples(), problem_dir_path,
93-
IN_EXAMPLE_FORMAT, OUT_EXAMPLE_FORMAT)
89+
config.etc_config.in_example_format, config.etc_config.out_example_format)
9490
emit_info("Created examples.")
9591

9692
code_file_path = os.path.join(
@@ -143,8 +139,8 @@ def emit_info(text):
143139
metadata_path = os.path.join(problem_dir_path, "metadata.json")
144140
Metadata(problem,
145141
os.path.basename(code_file_path),
146-
IN_EXAMPLE_FORMAT.replace("{}", "*"),
147-
OUT_EXAMPLE_FORMAT.replace("{}", "*"),
142+
config.etc_config.in_example_format.replace("{}", "*"),
143+
config.etc_config.out_example_format.replace("{}", "*"),
148144
lang,
149145
).save_to(metadata_path)
150146
emit_info("Saved metadata to {}".format(metadata_path))

tests/resources/test_atc_env/test_backup/agc029/A/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
},
99
"problem_id": "agc029_a"
1010
},
11-
"sample_in_pattern": "in_*.txt",
12-
"sample_out_pattern": "out_*.txt"
11+
"sample_in_pattern": "input_*.txt",
12+
"sample_out_pattern": "output_*.txt"
1313
}

0 commit comments

Comments
 (0)