@@ -341,10 +341,18 @@ def default_solution_path(generator_config: "GeneratorConfig") -> Path:
341341)
342342UNIQUE_DIRECTORY_KEYS : Final [Sequence [str ]] = ("data" , "test_group.yaml" , "include" )
343343ALLOWED_LINK_KEYS : Final [Sequence [str ]] = (
344- ".in.statement" ,
345- ".ans.statement" ,
346- ".in.download" ,
347- ".ans.download" ,
344+ "in.statement" ,
345+ "ans.statement" ,
346+ "in.download" ,
347+ "ans.download" ,
348+ )
349+ ALLOWED_LINK_VALUES : Final [Sequence [str ]] = (
350+ "in" ,
351+ "in.statement" ,
352+ "in.download" ,
353+ "ans" ,
354+ "ans.statement" ,
355+ "ans.download" ,
348356)
349357KNOWN_DIRECTORY_KEYS : Final [Sequence [str ]] = (
350358 "type" ,
@@ -622,27 +630,33 @@ def __init__(
622630
623631 # 3./4. hardcoded data or link to another file
624632 for ext in config .KNOWN_TEXT_DATA_EXTENSIONS :
625- if ext [1 :] in yaml :
626- value = yaml [ext [1 :]]
627- if ext == ".yaml" :
633+ key = ext [1 :]
634+ if key in yaml :
635+ value = yaml [key ]
636+ if key == "yaml" :
628637 # yaml can only be hardcoded (convert dict -> str)
629638 if not isinstance (value , str ):
630639 value = write_yaml (value )
631640 assert value is not None
632- if isinstance (value , dict ) and ext in ALLOWED_LINK_KEYS :
641+ if isinstance (value , dict ) and key in ALLOWED_LINK_KEYS :
633642 # 4. linked
634643 if "link" not in value or len (value ) != 1 :
635644 raise ParseException (
636- f"{ ext } should either be a string or a map with only the entry link."
645+ f"{ key } should either be a string or a map with only a link entry ."
637646 )
638647 value = value ["link" ]
639- assert_type (f"{ ext } .link" , value , str )
640- value_ext = f".{ value } "
641- if value_ext not in config .KNOWN_TEXT_DATA_EXTENSIONS :
648+ assert_type (f"{ key } .link" , value , str )
649+ if value not in ALLOWED_LINK_VALUES :
650+ raise ParseException (
651+ f"Unknown value `{ value } ` for for key { key } .link."
652+ )
653+ key_type = key .split ("." , 1 )[0 ]
654+ value_type = value .split ("." , 1 )[0 ]
655+ if key_type != value_type :
642656 raise ParseException (
643- f"Unknown value ` { value } ` for for key { ext } .link ."
657+ f"Crosslinking from { key } to { value } is not allowed ."
644658 )
645- self .linked [ext ] = value_ext
659+ self .linked [ext ] = f". { value } "
646660 else :
647661 # 3. hardcoded
648662 assert_type (ext , value , str )
0 commit comments