@@ -109,16 +109,25 @@ def fn_extract(origin_path, snippet_path, _language, first_line, last_line):
109109 raise UserError (f"Couldn't open '{ origin_path } ' or '{ snippet_path } '" )
110110
111111
112- def lint_json_file (snippet_abs_path , origin_path , snippet_number , first_line , prefix = None ):
112+ def lint_json_file (
113+ snippet_abs_path , origin_path , snippet_number , first_line , prefix = None
114+ ):
113115 with open (snippet_abs_path , "r" ) as f :
114116 json .loads (f .read ())
115117 if prefix :
116118 print (prefix , end = "" )
117119 print (f"PASS: Snippet { snippet_number } at '{ origin_path } :{ first_line } ' (json)" )
118120 return 0
119121
122+
120123def fn_check_syntax (
121- origin_path , snippet_path , language , first_line , _last_line , snippet_number , prefix = None
124+ origin_path ,
125+ snippet_path ,
126+ language ,
127+ first_line ,
128+ _last_line ,
129+ snippet_number ,
130+ prefix = None ,
122131):
123132 snippet_abs_path = os .path .abspath (snippet_path )
124133
@@ -136,7 +145,9 @@ def fn_check_syntax(
136145 raise UserError (f"Error when checking '{ origin_path } '" )
137146 case "json" :
138147 try :
139- lint_json_file (snippet_abs_path , origin_path , snippet_number , first_line , prefix )
148+ lint_json_file (
149+ snippet_abs_path , origin_path , snippet_number , first_line , prefix
150+ )
140151 except json .decoder .JSONDecodeError as e :
141152 raise UserError (f"Error when checking '{ snippet_abs_path } ': { str (e )} " )
142153 except Exception as e :
@@ -231,7 +242,7 @@ def _process_markdown_code_blocks(
231242 origin_paths_len = len (origin_paths )
232243
233244 for origin_paths_i , origin_path in enumerate (origin_paths ):
234- percentage = int (100 * (origin_paths_i + 1 )/ origin_paths_len )
245+ percentage = int (100 * (origin_paths_i + 1 ) / origin_paths_len )
235246 prefix = f"[{ origin_paths_i + 1 } /{ origin_paths_len } ({ percentage } %)] "
236247 offset = 0
237248 for i , code_block in enumerate (
@@ -269,7 +280,7 @@ def _process_markdown_code_blocks(
269280 code_block ["first_line" ],
270281 code_block ["last_line" ],
271282 snippet_number ,
272- prefix
283+ prefix ,
273284 )
274285 except Exception as e :
275286 if cleanup :
0 commit comments