2323 has_substitute ,
2424 inc_label ,
2525 log ,
26- message ,
27- MessageType ,
2826 normalize_yaml_value ,
2927 parse_yaml ,
3028 PrintBar ,
@@ -138,6 +136,8 @@ def build_problem_zip(problem: Problem, output: Path) -> bool:
138136 error ("zip needs the ruamel.yaml python3 library. Install python[3]-ruamel.yaml." )
139137 return False
140138
139+ bar = PrintBar ("Zip" , len (problem .name ) + 4 , item = problem )
140+
141141 from ruamel .yaml .comments import CommentedMap
142142
143143 languages = select_languages ([problem ])
@@ -167,7 +167,7 @@ def build_problem_zip(problem: Problem, output: Path) -> bool:
167167 if problem .custom_output :
168168 files .append ((f"{ OutputValidator .source_dir } /**/*" , True ))
169169
170- message ("preparing zip file content" , "Zip" , problem . path , color_type = MessageType . LOG )
170+ bar . log ("preparing zip file content" )
171171
172172 # prepare files inside dir
173173 export_dir = problem .tmpdir / "export"
@@ -257,11 +257,13 @@ def add_testcase(in_file: Path) -> None:
257257 text ,
258258 problem .settings .constants ,
259259 pattern = config .CONSTANT_SUBSTITUTE_REGEX ,
260- bar = PrintBar ( "Zip" ) ,
260+ bar = bar ,
261261 )
262262 f .unlink ()
263263 f .write_text (text )
264264
265+ bar = bar .start (output )
266+
265267 # move pdfs
266268 if config .args .legacy and languages :
267269 for type in PdfType :
@@ -277,7 +279,7 @@ def add_testcase(in_file: Path) -> None:
277279 if not file .exists ():
278280 continue
279281 if out .exists ():
280- warn (f"can't add { path } (already exists)." )
282+ bar . warn (f"can't add { path } (already exists)." )
281283 file .unlink ()
282284 continue
283285 out .parent .mkdir (parents = True , exist_ok = True )
@@ -370,12 +372,7 @@ def add_testcase(in_file: Path) -> None:
370372 if f .is_file ():
371373 out = Path ("problem_statement" ) / f .relative_to (problem .path / d )
372374 if out .exists ():
373- message (
374- f"Can not export { f .relative_to (problem .path )} as { out } " ,
375- "Zip" ,
376- output ,
377- color_type = MessageType .WARN ,
378- )
375+ bar .warn (f"Cannot export { f .relative_to (problem .path )} as { out } " )
379376 else :
380377 add_file (out , f )
381378 shutil .rmtree (export_dir / d )
@@ -397,7 +394,7 @@ def add_testcase(in_file: Path) -> None:
397394 write_yaml (yaml_data , yaml_path )
398395
399396 # Build .ZIP file.
400- message ("writing zip file" , "Zip" , output , color_type = MessageType . LOG )
397+ bar . log ("writing zip file" )
401398 try :
402399 zf = zipfile .ZipFile (output , mode = "w" , compression = zipfile .ZIP_DEFLATED , allowZip64 = False )
403400
@@ -410,7 +407,7 @@ def add_testcase(in_file: Path) -> None:
410407
411408 # Done.
412409 zf .close ()
413- message ("done" , "Zip" , color_type = MessageType . LOG )
410+ bar . log ("done" )
414411 eprint ()
415412 except Exception :
416413 return False
0 commit comments