44import re
55import textwrap
66import typing
7+ from collections .abc import Sequence
78from dataclasses import dataclass , field
89from typing import Any
910
@@ -101,21 +102,36 @@ def from_dict(cls, data: dict[str, Any]) -> Self:
101102
102103
103104@dataclass
104- class DataTable :
105+ class ExamplesTable :
105106 location : Location
106107 name : str | None = None
107- tableHeader : Row | None = None
108- tableBody : list [Row ] | None = field (default_factory = list )
108+ table_header : Row | None = None
109+ table_body : list [Row ] | None = field (default_factory = list )
109110
110111 @classmethod
111112 def from_dict (cls , data : dict [str , Any ]) -> Self :
112113 return cls (
113114 location = Location .from_dict (data ["location" ]),
114115 name = data .get ("name" ),
115- tableHeader = Row .from_dict (data ["tableHeader" ]) if data .get ("tableHeader" ) else None ,
116- tableBody = [Row .from_dict (row ) for row in data .get ("tableBody" , [])],
116+ table_header = Row .from_dict (data ["tableHeader" ]) if data .get ("tableHeader" ) else None ,
117+ table_body = [Row .from_dict (row ) for row in data .get ("tableBody" , [])],
118+ )
119+
120+
121+ @dataclass
122+ class DataTable :
123+ location : Location
124+ rows : list [Row ]
125+
126+ @classmethod
127+ def from_dict (cls , data : dict [str , Any ]) -> Self :
128+ return cls (
129+ location = Location .from_dict (data ["location" ]), rows = [Row .from_dict (row ) for row in data .get ("rows" , [])]
117130 )
118131
132+ def raw (self ) -> Sequence [Sequence [object ]]:
133+ return [[cell .value for cell in row .cells ] for row in self .rows ]
134+
119135
120136@dataclass
121137class DocString :
@@ -135,23 +151,23 @@ def from_dict(cls, data: dict[str, Any]) -> Self:
135151@dataclass
136152class Step :
137153 id : str
138- keyword : str
139- keywordType : str
140154 location : Location
155+ keyword : str
156+ keyword_type : str
141157 text : str
142- dataTable : DataTable | None = None
143- docString : DocString | None = None
158+ datatable : DataTable | None = None
159+ docstring : DocString | None = None
144160
145161 @classmethod
146162 def from_dict (cls , data : dict [str , Any ]) -> Self :
147163 return cls (
148164 id = data ["id" ],
149- keyword = data ["keyword" ].strip (),
150- keywordType = data ["keywordType" ],
151165 location = Location .from_dict (data ["location" ]),
166+ keyword = data ["keyword" ].strip (),
167+ keyword_type = data ["keywordType" ],
152168 text = data ["text" ],
153- dataTable = DataTable .from_dict (data ["dataTable" ]) if data .get ("dataTable" ) else None ,
154- docString = DocString .from_dict (data ["docString" ]) if data .get ("docString" ) else None ,
169+ datatable = DataTable .from_dict (data ["dataTable" ]) if data .get ("dataTable" ) else None ,
170+ docstring = DocString .from_dict (data ["docString" ]) if data .get ("docString" ) else None ,
155171 )
156172
157173
@@ -169,33 +185,33 @@ def from_dict(cls, data: dict[str, Any]) -> Self:
169185@dataclass
170186class Scenario :
171187 id : str
172- keyword : str
173188 location : Location
189+ keyword : str
174190 name : str
175191 description : str
176192 steps : list [Step ]
177193 tags : list [Tag ]
178- examples : list [DataTable ] = field (default_factory = list )
194+ examples : list [ExamplesTable ] = field (default_factory = list )
179195
180196 @classmethod
181197 def from_dict (cls , data : dict [str , Any ]) -> Self :
182198 return cls (
183199 id = data ["id" ],
184- keyword = data ["keyword" ],
185200 location = Location .from_dict (data ["location" ]),
201+ keyword = data ["keyword" ],
186202 name = data ["name" ],
187203 description = data ["description" ],
188204 steps = [Step .from_dict (step ) for step in data ["steps" ]],
189205 tags = [Tag .from_dict (tag ) for tag in data ["tags" ]],
190- examples = [DataTable .from_dict (example ) for example in data ["examples" ]],
206+ examples = [ExamplesTable .from_dict (example ) for example in data ["examples" ]],
191207 )
192208
193209
194210@dataclass
195211class Rule :
196212 id : str
197- keyword : str
198213 location : Location
214+ keyword : str
199215 name : str
200216 description : str
201217 tags : list [Tag ]
@@ -205,8 +221,8 @@ class Rule:
205221 def from_dict (cls , data : dict [str , Any ]) -> Self :
206222 return cls (
207223 id = data ["id" ],
208- keyword = data ["keyword" ],
209224 location = Location .from_dict (data ["location" ]),
225+ keyword = data ["keyword" ],
210226 name = data ["name" ],
211227 description = data ["description" ],
212228 tags = [Tag .from_dict (tag ) for tag in data ["tags" ]],
@@ -217,8 +233,8 @@ def from_dict(cls, data: dict[str, Any]) -> Self:
217233@dataclass
218234class Background :
219235 id : str
220- keyword : str
221236 location : Location
237+ keyword : str
222238 name : str
223239 description : str
224240 steps : list [Step ]
@@ -227,8 +243,8 @@ class Background:
227243 def from_dict (cls , data : dict [str , Any ]) -> Self :
228244 return cls (
229245 id = data ["id" ],
230- keyword = data ["keyword" ],
231246 location = Location .from_dict (data ["location" ]),
247+ keyword = data ["keyword" ],
232248 name = data ["name" ],
233249 description = data ["description" ],
234250 steps = [Step .from_dict (step ) for step in data ["steps" ]],
@@ -252,8 +268,8 @@ def from_dict(cls, data: dict[str, Any]) -> Self:
252268
253269@dataclass
254270class Feature :
255- keyword : str
256271 location : Location
272+ keyword : str
257273 tags : list [Tag ]
258274 name : str
259275 description : str
@@ -262,8 +278,8 @@ class Feature:
262278 @classmethod
263279 def from_dict (cls , data : dict [str , Any ]) -> Self :
264280 return cls (
265- keyword = data ["keyword" ],
266281 location = Location .from_dict (data ["location" ]),
282+ keyword = data ["keyword" ],
267283 tags = [Tag .from_dict (tag ) for tag in data ["tags" ]],
268284 name = data ["name" ],
269285 description = data ["description" ],
0 commit comments