@@ -235,7 +235,7 @@ def get_class_details(global_: Dict[str,
235
235
write = True ))
236
236
else :
237
237
global_ [class_name ]["prop_definition" ].append (
238
- HydraClassProp ("vocab:" + prop , prop , required = flag ,
238
+ HydraClassProp ("vocab:" . format ( prop ) , prop , required = flag ,
239
239
read = True , write = True ))
240
240
else :
241
241
global_ [class_name ]["prop_definition" ].append (HydraClassProp (
@@ -342,8 +342,7 @@ def check_for_ref(global_: Dict[str, Any],
342
342
pass
343
343
# cannot parse because no external ref
344
344
345
- print ("Cannot parse path" + path +
346
- " because no ref to local class provided" )
345
+ print ("Cannot parse path {} because no ref to local class provided" .format (path ))
347
346
return ""
348
347
349
348
@@ -383,8 +382,7 @@ def get_parameters(global_: Dict[str, Any],
383
382
# check if class has been pared
384
383
if parameter ["schema" ]["$ref" ].split (
385
384
'/' )[2 ] in global_ ["class_names" ]:
386
- param = "vocab:" + \
387
- parameter ["schema" ]["$ref" ].split ('/' )[2 ]
385
+ param = "vocab:{}" .format (parameter ["schema" ]["$ref" ].split ('/' )[2 ])
388
386
389
387
else :
390
388
# if not go to that location and parse and add
@@ -394,8 +392,7 @@ def get_parameters(global_: Dict[str, Any],
394
392
parameter ["schema" ]["$ref" ]),
395
393
parameter ["schema" ]["$ref" ].split ('/' )[2 ],
396
394
path = path )
397
- param = "vocab:" + \
398
- parameter ["schema" ]["$ref" ].split ('/' )[2 ]
395
+ param = "vocab:{}" .format (parameter ["schema" ]["$ref" ].split ('/' )[2 ])
399
396
except KeyError :
400
397
param = ""
401
398
@@ -430,15 +427,14 @@ def get_ops(global_: Dict[str, Any], path: str,
430
427
response ),
431
428
"description" : responses [response ]["description" ]})
432
429
try :
433
- op_returns = "vocab:" + \
434
- responses [response ]["schema" ]["$ref" ].split ('/' )[2 ]
430
+ op_returns = "vocab:{}" . format (
431
+ responses [response ]["schema" ]["$ref" ].split ('/' )[2 ])
435
432
except KeyError :
436
433
pass
437
434
if op_returns is None :
438
435
try :
439
- op_returns = "vocab:" + \
440
- responses [response ]["schema" ]["items" ]["$ref" ].\
441
- split ('/' )[2 ]
436
+ op_returns = "vocab:{}" .format (
437
+ responses [response ]["schema" ]["items" ]["$ref" ].split ('/' )[2 ])
442
438
except KeyError :
443
439
op_returns = try_catch_replacement (
444
440
responses [response ]["schema" ], "type" , None )
@@ -451,7 +447,7 @@ def get_ops(global_: Dict[str, Any], path: str,
451
447
global_ [class_name ]["op_definition" ].append (HydraClassOp (
452
448
op_name , op_method .upper (), op_expects , op_returns , op_status ))
453
449
else :
454
- print ("Method on path" + path + " already present !" )
450
+ print ("Method on path {} already present !" . format ( path ) )
455
451
456
452
457
453
def get_paths (global_ : Dict [str , Any ]) -> None :
@@ -491,7 +487,7 @@ def parse(doc: Dict[str, Any]) -> Dict[str, Any]:
491
487
baseURL = try_catch_replacement (doc , "host" , "localhost" )
492
488
name = try_catch_replacement (doc , "basePath" , "api" )
493
489
schemes = try_catch_replacement (doc , "schemes" , "http" )
494
- api_doc = HydraDoc (name , title , desc , name , schemes [ 0 ] + " ://" + baseURL )
490
+ api_doc = HydraDoc (name , title , desc , name , "{} ://{}" . format ( schemes [ 0 ], baseURL ) )
495
491
get_paths (global_ )
496
492
for name in global_ ["class_names" ]:
497
493
for prop in global_ [name ]["prop_definition" ]:
@@ -521,8 +517,8 @@ def dump_documentation(hydra_doc: Dict[str, Any]) -> str:
521
517
"""
522
518
dump = json .dumps (hydra_doc , indent = 4 , sort_keys = True )
523
519
hydra_doc = '''"""\n Generated API Documentation for Server API using
524
- server_doc_gen.py."""\n \n doc = %s ''' % dump
525
- hydra_doc = hydra_doc + ' \n '
520
+ server_doc_gen.py."""\n \n doc = {} ''' . format ( dump )
521
+ hydra_doc = '{} \n '. format ( hydra_doc )
526
522
hydra_doc = hydra_doc .replace ('true' , '"true"' )
527
523
hydra_doc = hydra_doc .replace ('false' , '"false"' )
528
524
hydra_doc = hydra_doc .replace ('null' , '"null"' )
0 commit comments