1414
1515import debug # pyflakes:ignore
1616
17+ from ietf .utils import tool_version
1718from ietf .utils .log import log , assertion
18- from ietf .utils .models import VersionInfo
1919from ietf .utils .pipe import pipe
2020from ietf .utils .test_runner import set_coverage_checking
2121
@@ -177,8 +177,10 @@ def check_file_txt(self, path):
177177 model_list = list (set (model_list ))
178178
179179 command = "xym"
180- cmd_version = VersionInfo .objects .get (command = command ).version
181- message = "%s:\n %s\n \n " % (cmd_version , out .replace ('\n \n ' ,'\n ' ).strip () if code == 0 else err )
180+ message = "{version}:\n {output}\n \n " .format (
181+ version = tool_version [command ],
182+ output = out .replace ('\n \n ' , '\n ' ).strip () if code == 0 else err ,
183+ )
182184
183185 results .append ({
184186 "name" : name ,
@@ -209,7 +211,6 @@ def check_file_txt(self, path):
209211 # pyang
210212 cmd_template = settings .SUBMIT_PYANG_COMMAND
211213 command = [ w for w in cmd_template .split () if not '=' in w ][0 ]
212- cmd_version = VersionInfo .objects .get (command = command ).version
213214 cmd = cmd_template .format (libs = modpath , model = path )
214215 venv_path = os .environ .get ('VIRTUAL_ENV' ) or os .path .join (os .getcwd (), 'env' )
215216 venv_bin = os .path .join (venv_path , 'bin' )
@@ -238,14 +239,17 @@ def check_file_txt(self, path):
238239 except ValueError :
239240 pass
240241 #passed = passed and code == 0 # For the submission tool. Yang checks always pass
241- message += "%s: %s:\n %s\n " % (cmd_version , cmd_template , out + "No validation errors\n " if (code == 0 and len (err ) == 0 ) else out + err )
242+ message += "{version}: {template}:\n {output}\n " .format (
243+ version = tool_version [command ],
244+ template = cmd_template ,
245+ output = out + "No validation errors\n " if (code == 0 and len (err ) == 0 ) else out + err ,
246+ )
242247
243248 # yanglint
244249 set_coverage_checking (False ) # we can't count the following as it may or may not be run, depending on setup
245250 if settings .SUBMIT_YANGLINT_COMMAND and os .path .exists (settings .YANGLINT_BINARY ):
246251 cmd_template = settings .SUBMIT_YANGLINT_COMMAND
247252 command = [ w for w in cmd_template .split () if not '=' in w ][0 ]
248- cmd_version = VersionInfo .objects .get (command = command ).version
249253 cmd = cmd_template .format (model = path , rfclib = settings .SUBMIT_YANG_RFC_MODEL_DIR , tmplib = workdir ,
250254 draftlib = settings .SUBMIT_YANG_DRAFT_MODEL_DIR , ianalib = settings .SUBMIT_YANG_IANA_MODEL_DIR ,
251255 cataloglib = settings .SUBMIT_YANG_CATALOG_MODEL_DIR , )
@@ -264,7 +268,11 @@ def check_file_txt(self, path):
264268 except ValueError :
265269 pass
266270 #passed = passed and code == 0 # For the submission tool. Yang checks always pass
267- message += "%s: %s:\n %s\n " % (cmd_version , cmd_template , out + "No validation errors\n " if (code == 0 and len (err ) == 0 ) else out + err )
271+ message += "{version}: {template}:\n {output}\n " .format (
272+ version = tool_version [command ],
273+ template = cmd_template ,
274+ output = out + "No validation errors\n " if (code == 0 and len (err ) == 0 ) else out + err ,
275+ )
268276 set_coverage_checking (True )
269277 else :
270278 errors += 1
@@ -293,4 +301,4 @@ def check_file_txt(self, path):
293301 items = [ e for res in results for e in res ["items" ] ]
294302 info ['items' ] = items
295303 info ['code' ]['yang' ] = model_list
296- return passed , message , errors , warnings , info
304+ return passed , message , errors , warnings , info
0 commit comments