@@ -61,6 +61,18 @@ def line_number_of(path: Path, case: dict[str, Any]) -> int:
61
61
1 ,
62
62
)
63
63
64
+ def extract_kind_and_spec (key : str ) -> (str , str ):
65
+ """
66
+ Extracts specification number and kind from the defined key
67
+ """
68
+ can_have_spec = ["rfc" , "iso" ]
69
+ if not any (key .startswith (el ) for el in can_have_spec ):
70
+ return key , ""
71
+ number = re .search (r"\d+" , key )
72
+ spec = "" if number is None else number .group (0 )
73
+ kind = key .removesuffix (spec )
74
+ return kind , spec
75
+
64
76
65
77
def main ():
66
78
# Clear annotations which may have been emitted by a previous run.
@@ -82,20 +94,33 @@ def main():
82
94
line = error .lineno ,
83
95
col = error .pos + 1 ,
84
96
title = str (error ),
97
+ message = f"cannot load { path } "
85
98
)
86
99
sys .stdout .write (error )
100
+ continue
87
101
88
102
for test_case in contents :
89
103
specifications = test_case .get ("specification" )
90
104
if specifications is not None :
91
105
for each in specifications :
92
106
quote = each .pop ("quote" , "" )
93
- (kind , section ), = each .items ()
107
+ (key , section ), = each .items ()
94
108
95
- number = re .search (r"\d+" , kind )
96
- spec = "" if number is None else number .group (0 )
109
+ (kind , spec ) = extract_kind_and_spec (key )
110
+
111
+ url_template = version_urls [kind ]
112
+ if url_template is None :
113
+ error = annotation (
114
+ level = "error" ,
115
+ path = path ,
116
+ line = line_number_of (path , test_case ),
117
+ title = f"unsupported template '{ kind } '" ,
118
+ message = f"cannot find a URL template for '{ kind } '"
119
+ )
120
+ sys .stdout .write (error )
121
+ continue
97
122
98
- url = version_urls [ kind ] .expand (
123
+ url = url_template .expand (
99
124
spec = spec ,
100
125
section = section ,
101
126
)
0 commit comments