15
15
from atcodertools .client .atcoder import AtCoderClient , Contest , LoginError
16
16
from atcodertools .client .models .problem import Problem
17
17
from atcodertools .client .models .problem_content import InputFormatDetectionError , SampleDetectionError
18
+ from atcodertools .codegen .code_style_config import DEFAULT_WORKSPACE_DIR_PATH
18
19
from atcodertools .codegen .models .code_gen_args import CodeGenArgs
19
- from atcodertools .codegen . code_style_config import DEFAULT_WORKSPACE_DIR_PATH , SUPPORTED_LANGUAGES
20
+ from atcodertools .common . language import ALL_LANGUAGES , CPP
20
21
from atcodertools .config .config import Config
21
22
from atcodertools .constprediction .constants_prediction import predict_constants
22
23
from atcodertools .fileutils .create_contest_file import create_examples , \
26
27
MultiplePredictionResultsError , predict_format
27
28
from atcodertools .tools import get_default_config_path
28
29
from atcodertools .tools .models .metadata import Metadata
29
- from atcodertools .tools .templates import get_default_template_path
30
30
from atcodertools .tools .utils import with_color
31
31
32
-
33
32
fmt = "%(asctime)s %(levelname)s: %(message)s"
34
33
logging .basicConfig (level = logging .INFO , format = fmt )
35
34
@@ -38,12 +37,6 @@ class BannedFileDetectedError(Exception):
38
37
pass
39
38
40
39
41
- def extension (lang : str ):
42
- if lang == 'rust' :
43
- return 'rs'
44
- return lang
45
-
46
-
47
40
IN_EXAMPLE_FORMAT = "in_{}.txt"
48
41
OUT_EXAMPLE_FORMAT = "out_{}.txt"
49
42
@@ -102,7 +95,7 @@ def emit_info(text):
102
95
103
96
code_file_path = os .path .join (
104
97
problem_dir_path ,
105
- "main.{}" .format (extension ( lang ) ))
98
+ "main.{}" .format (lang . extension ))
106
99
107
100
# If there is an existing code, just create backup
108
101
if os .path .exists (code_file_path ):
@@ -121,7 +114,8 @@ def emit_info(text):
121
114
122
115
try :
123
116
prediction_result = predict_format (content )
124
- emit_info (with_color ("Format prediction succeeded" , Fore .LIGHTGREEN_EX ))
117
+ emit_info (
118
+ with_color ("Format prediction succeeded" , Fore .LIGHTGREEN_EX ))
125
119
except (NoPredictionResultError , MultiplePredictionResultsError ) as e :
126
120
prediction_result = FormatPredictionResult .empty_result ()
127
121
if isinstance (e , NoPredictionResultError ):
@@ -210,8 +204,6 @@ def prepare_contest(atcoder_client: AtCoderClient,
210
204
contest_dir_path )
211
205
212
206
213
- DEFAULT_LANG = "cpp"
214
-
215
207
USER_CONFIG_PATH = os .path .join (
216
208
expanduser ("~" ), ".atcodertools.toml" )
217
209
@@ -254,16 +246,16 @@ def main(prog, args):
254
246
255
247
parser .add_argument ("--lang" ,
256
248
help = "Programming language of your template code, {}.\n "
257
- .format (" or " .join (SUPPORTED_LANGUAGES )) + "[Default] {}" .format (DEFAULT_LANG ))
249
+ .format (" or " .join ([ lang . name for lang in ALL_LANGUAGES ] )) + "[Default] {}" .format (CPP . name ))
258
250
259
251
parser .add_argument ("--template" ,
260
- help = "File path to your template code\n {0}{1 }" .format (
261
- "[Default (C++)] {} \n " .format (
262
- get_default_template_path ( 'cpp' )),
263
- "[Default (Java)] {}" . format (
264
- get_default_template_path ( 'java' )),
265
- "[Default (Rust)] {}" . format (
266
- get_default_template_path ( 'rust' ))),
252
+ help = "File path to your template code\n {}" .format (
253
+ "\n " .join (
254
+ [ "[Default ({dname})] {path}" . format (
255
+ dname = lang . display_name ,
256
+ path = lang . default_template_path
257
+ ) for lang in ALL_LANGUAGES ]
258
+ ))
267
259
)
268
260
269
261
# Deleted functionality
0 commit comments