1111from typing import cast , Final , Literal , Optional , overload , TypeVar
1212
1313from colorama import Fore , Style
14+ from ruamel .yaml .comments import CommentedMap , CommentedSeq
1415
1516from bapctools import config , parallel , program , run , validate , visualize
1617from bapctools .problem import Problem
2627 fatal ,
2728 get_basedirs ,
2829 glob ,
29- has_ryaml ,
3030 hash_file_content ,
3131 hash_string ,
3232 is_relative_to ,
3535 PrintBar ,
3636 ProgressBar ,
3737 read_yaml ,
38- require_ruamel ,
3938 ryaml_get_or_add ,
4039 shorten_path ,
4140 substitute ,
4443)
4544from bapctools .verdicts import Verdict
4645
47- if has_ryaml :
48- import ruamel .yaml
49-
50-
5146YAML_TYPE = Optional [str | dict [object , object ]]
5247
5348INCLUSIVE_RANGE_REGEX = re .compile (r"^(-?\d+)\.\.=(-?\d+)$" )
@@ -721,7 +716,7 @@ def get(key: str, default: T) -> T:
721716
722717 def write (self ) -> None :
723718 data = {k : v for k , v in vars (self ).items () if not k .startswith ("_" )}
724- write_yaml (data , self ._path , allow_yamllib = True )
719+ write_yaml (data , self ._path )
725720
726721 def link (
727722 t ,
@@ -2244,7 +2239,6 @@ def update_gitignore_file(self) -> None:
22442239
22452240 # add all testcases specified as copy keys in the generators.yaml
22462241 # can handle files and complete directories
2247- @require_ruamel ("generate --upgrade" , False )
22482242 def add (self , to_add : Sequence [Path ]) -> bool :
22492243 if self .n_parse_error > 0 :
22502244 return False
@@ -2268,12 +2262,12 @@ def add(self, to_add: Sequence[Path]) -> bool:
22682262 generators_yaml = self .problem .path / "generators" / "generators.yaml"
22692263 data = read_yaml (generators_yaml )
22702264 if data is None :
2271- data = ruamel . yaml . comments . CommentedMap ()
2272- assert isinstance (data , ruamel . yaml . comments . CommentedMap )
2265+ data = CommentedMap ()
2266+ assert isinstance (data , CommentedMap )
22732267
22742268 parent = ryaml_get_or_add (data , "data" )
22752269 parent = ryaml_get_or_add (parent , "secret" )
2276- entry = ryaml_get_or_add (parent , "data" , ruamel . yaml . comments . CommentedSeq )
2270+ entry = ryaml_get_or_add (parent , "data" , CommentedSeq )
22772271
22782272 bar = ProgressBar ("Adding" , items = in_files )
22792273 for in_file in sorted (in_files , key = lambda x : x .name ):
@@ -2283,12 +2277,10 @@ def add(self, to_add: Sequence[Path]) -> bool:
22832277 elif in_file in known :
22842278 bar .log ("already found in generators.yaml. Skipping." )
22852279 else :
2286- entry .append (ruamel . yaml . comments . CommentedMap ())
2280+ entry .append (CommentedMap ())
22872281 path_in_gen = in_file .relative_to ("generators" )
22882282 name = path_in_gen .with_suffix ("" ).as_posix ().replace ("/" , "_" )
2289- new = ruamel .yaml .comments .CommentedMap (
2290- {"copy" : path_in_gen .with_suffix ("" ).as_posix ()}
2291- )
2283+ new = CommentedMap ({"copy" : path_in_gen .with_suffix ("" ).as_posix ()})
22922284 new .fa .set_flow_style ()
22932285 entry [- 1 ][str (name )] = new
22942286 bar .log ("added to generators.yaml." )
@@ -2302,7 +2294,6 @@ def add(self, to_add: Sequence[Path]) -> bool:
23022294 return True
23032295
23042296 # reorder all testcases in the given directories
2305- @require_ruamel ("generate --reorder" , False )
23062297 def reorder (self ) -> bool :
23072298 if self .n_parse_error > 0 :
23082299 return False
0 commit comments