@@ -110,7 +110,9 @@ def fn_extract(origin_path, snippet_path, _language, first_line, last_line):
110110 raise UserError (f"Couldn't open '{ origin_path } ' or '{ snippet_path } '" )
111111
112112
113- def fn_check_syntax (origin_path , snippet_path , language , first_line , _last_line , snippet_number ):
113+ def fn_check_syntax (
114+ origin_path , snippet_path , language , first_line , _last_line , snippet_number
115+ ):
114116 snippet_abs_path = os .path .abspath (snippet_path )
115117
116118 if not os .path .exists (snippet_path ):
@@ -120,7 +122,9 @@ def fn_check_syntax(origin_path, snippet_path, language, first_line, _last_line,
120122
121123 match language :
122124 case "cf" :
123- r = lint_policy_file (snippet_abs_path , origin_path , first_line + 1 , snippet_number )
125+ r = lint_policy_file (
126+ snippet_abs_path , origin_path , first_line + 1 , snippet_number
127+ )
124128 if r != 0 :
125129 raise UserError (f"Error when checking '{ origin_path } '" )
126130 case "json" :
@@ -183,6 +187,7 @@ def fn_autoformat(_origin_path, snippet_path, language, _first_line, _last_line)
183187 except json .decoder .JSONDecodeError :
184188 raise UserError (f"Invalid json in '{ snippet_path } '" )
185189
190+
186191def _translate_language (x ):
187192 if x == "cf3" or x == "cfengine3" :
188193 return "cf"
@@ -193,6 +198,7 @@ def _translate_language(x):
193198
194199SUPPORTED_LANGUAGES = ["cf" , "cfengine3" , "cf3" , "json" , "yml" , "yaml" ]
195200
201+
196202def _process_markdown_code_blocks (
197203 path , languages , extract , syntax_check , output_check , autoformat , replace , cleanup
198204):
@@ -282,6 +288,7 @@ def _process_markdown_code_blocks(
282288 if cleanup :
283289 os .remove (snippet_path )
284290
291+
285292def _run_black ():
286293 path = "."
287294 assert os .path .isdir (path )
@@ -294,7 +301,9 @@ def _run_black():
294301 cwd = path ,
295302 )
296303 except :
297- raise UserError ("Encountered an error running black\n Install: pipx install black" )
304+ raise UserError (
305+ "Encountered an error running black\n Install: pipx install black"
306+ )
298307
299308
300309def _run_prettier ():
@@ -309,7 +318,10 @@ def _run_prettier():
309318 cwd = path ,
310319 )
311320 except :
312- raise UserError ("Encountered an error running prettier\n Install: npm install --global prettier" )
321+ raise UserError (
322+ "Encountered an error running prettier\n Install: npm install --global prettier"
323+ )
324+
313325
314326def update_docs () -> int :
315327 """
@@ -329,7 +341,7 @@ def update_docs() -> int:
329341 print ("Formatting markdown code blocks according to our rules..." )
330342 _process_markdown_code_blocks (
331343 path = "." ,
332- languages = ["json" ], # TODO: Add cfengine3 here
344+ languages = ["json" ], # TODO: Add cfengine3 here
333345 extract = True ,
334346 syntax_check = False ,
335347 output_check = False ,
0 commit comments