Skip to content

Commit 67215fe

Browse files
authored
New option to skip preparing existing problem directories (kyuridenamida#222)
* add gen option to skip processing each problem for which a directory already exists * add test for skip existing problem * add dummy of skip_existing_problem for get_config() * fix new line style * fix help for --skip-existing-problem * rename skip_existing_problem to skip_existing_problems * make info about skipped preparation more detailed
1 parent a8b8462 commit 67215fe

Some content is hidden

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

49 files changed

+354
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion

atcodertools/config/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def load(cls, fp: TextIO, args: Optional[Namespace] = None):
4949
dict(
5050
download_without_login=args.without_login,
5151
parallel_download=args.parallel,
52-
save_no_session_cache=args.save_no_session_cache))
52+
save_no_session_cache=args.save_no_session_cache,
53+
skip_existing_problems=args.skip_existing_problems))
5354

5455
return Config(
5556
code_style_config=CodeStyleConfig(**code_style_config_dic),

atcodertools/config/etc_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ def __init__(self,
44
download_without_login: str = False,
55
parallel_download: bool = False,
66
save_no_session_cache: bool = False,
7+
skip_existing_problems: bool = False,
78
in_example_format: str = "in_{}.txt",
89
out_example_format: str = "out_{}.txt",
910
):
1011
self.download_without_login = download_without_login
1112
self.parallel_download = parallel_download
1213
self.save_no_session_cache = save_no_session_cache
14+
self.skip_existing_problems = skip_existing_problems
1315
self.in_example_format = in_example_format
1416
self.out_example_format = out_example_format

atcodertools/tools/atcodertools-default.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ lang = 'cpp' # 'cpp' or 'java' (Currently)
2626
download_without_login=false
2727
parallel_download=false
2828
save_no_session_cache=false
29+
skip_existing_problems=false
2930
in_example_format="in_{}.txt"
3031
out_example_format="out_{}.txt"

atcodertools/tools/codegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def main(prog, args, output_file=sys.stdout):
159159

160160
args.workspace = DEFAULT_WORKSPACE_DIR_PATH # dummy for get_config()
161161
args.parallel = False # dummy for get_config()
162+
args.skip_existing_problems = False # dummy for get_config()
162163
config = get_config(args)
163164

164165
client = AtCoderClient()

atcodertools/tools/envgen.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ def emit_warning(text):
6969
def emit_info(text):
7070
logger.info("Problem {}: {}".format(pid, text))
7171

72+
# Return if a directory for the problem already exists
73+
if config.etc_config.skip_existing_problems:
74+
if os.path.exists(problem_dir_path):
75+
emit_info(
76+
f"Skipped preparation because the directory already exists: {problem_dir_path}")
77+
return
78+
7279
emit_info('{} is used for template'.format(template_code_path))
7380

7481
# Fetch problem data from the statement
@@ -277,6 +284,11 @@ def main(prog, args):
277284
help="Save no session cache to avoid security risk",
278285
default=None)
279286

287+
parser.add_argument("--skip-existing-problems",
288+
action="store_true",
289+
help="Skip processing every problem for which a directory already exists",
290+
default=None)
291+
280292
parser.add_argument("--config",
281293
help="File path to your config file\n{0}{1}".format("[Default (Primary)] {}\n".format(
282294
USER_CONFIG_PATH),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BBW
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BWBWBW
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"code_filename": "main.cpp",
3+
"judge": {
4+
"judge_type": "normal"
5+
},
6+
"lang": "cpp",
7+
"problem": {
8+
"alphabet": "A",
9+
"contest": {
10+
"contest_id": "agc029"
11+
},
12+
"problem_id": "agc029_a"
13+
},
14+
"sample_in_pattern": "input_*.txt",
15+
"sample_out_pattern": "output_*.txt"
16+
}

0 commit comments

Comments
 (0)