39
39
args .output_path
40
40
)
41
41
42
- print 'argv: '
43
- print sys .argv
44
- print 'args:'
45
- print args
42
+ print ( 'argv: ' )
43
+ print ( sys .argv )
44
+ print ( 'args:' )
45
+ print ( args )
46
46
################################################################
47
47
# local imports
48
48
sys .path .append (os .path .join (args .backend_path ,'output_stage' ))
@@ -138,7 +138,7 @@ def create_visio(self): # support up to two tables per flow:
138
138
try :
139
139
new_line = visio_dicts [i ][(table .flexPipe ,pipe_index [table .flexPipe ])].replace ('__TEXT__' ,table_text )
140
140
except KeyError :
141
- print 'Warning: [visio: %s] table skipped, no place in template' % visio
141
+ print ( 'Warning: [visio: %s] table skipped, no place in template' % visio )
142
142
pass
143
143
o .write (new_line )
144
144
pipe_index [table .flexPipe ] += 1
@@ -147,7 +147,7 @@ def create_visio(self): # support up to two tables per flow:
147
147
o .write (line )
148
148
149
149
def get_header_key (self ,key0 ,key1 ):
150
- if args .verbose : print ('getting key: %s.%s' % (key0 ,key1 ))
150
+ if args .verbose : print ('getting key: %s.%s' % (key0 ,key1 ))
151
151
# if key0 in self.sai_fixed_headers:
152
152
# inner = self.sai_fixed_headers[key0]
153
153
# if key1 in inner:
@@ -245,7 +245,7 @@ def interp_p4c_json_stage_output(lib,json_path):
245
245
# bmv2 json doesn't save tables in order, need to search by 'base_default_next' field
246
246
247
247
print ('interp ' + json_path )
248
- with open (json_path ,'rb ' ) as json_file :
248
+ with open (json_path ,'r ' ) as json_file :
249
249
j = json .load (json_file )
250
250
for pipe in lib .flexPipes :
251
251
# TODO (readability) make dict prio to prevent the below loop
@@ -264,7 +264,7 @@ def interp_p4c_json_stage_output(lib,json_path):
264
264
while inserted_tables < len (tables ) and next_table_name != None :
265
265
for table in tables :
266
266
table_name = table ['name' ]
267
- if args .verbose : print "pipe %s. table %s" % (pipe , table_name )
267
+ if args .verbose : print ( "pipe %s. table %s" % (pipe , table_name ) )
268
268
if table_name != next_table_name and next_table_name != None :
269
269
continue
270
270
table_size = table ['max_size' ]
@@ -294,7 +294,7 @@ def interp_p4c_json_stage_output(lib,json_path):
294
294
# key_params.append(key['mlnx_extract']);
295
295
# custom_key_offset.append(i)
296
296
# if args.verbose : print 'getting custom key ' + json_target
297
- if args .verbose : print 'getting predefined key ' + json_target
297
+ if args .verbose : print ( 'getting predefined key ' + json_target )
298
298
299
299
#print key_params
300
300
if (len (custom_key_offset ) > 1 ):
@@ -308,10 +308,10 @@ def interp_p4c_json_stage_output(lib,json_path):
308
308
#TODO- process static entries
309
309
if args .verbose and 'entries' in table :
310
310
for ent in table ['entries' ]:
311
- print ent ['match_key' ]
311
+ print ( ent ['match_key' ])
312
312
# add to table
313
313
next_table_name = table ['base_default_next' ]
314
- if args .verbose : print 'inserted tables: %d' % inserted_tables
314
+ if args .verbose : print ( 'inserted tables: %d' % inserted_tables )
315
315
lib .pipe_table_count [pipe ]= inserted_tables
316
316
return
317
317
@@ -336,8 +336,8 @@ def is_field_pre_extracted(json_obj, header, field_name):
336
336
if len (fldlist ) == 4 :
337
337
return fldlist [3 ]
338
338
else :
339
- print 'Error parsing header field: ' + fld
340
- print fldlist
339
+ print ( 'Error parsing header field: ' + fld )
340
+ print ( fldlist )
341
341
exit (0 )
342
342
break
343
343
break
@@ -361,11 +361,11 @@ def is_field_pre_extracted(json_obj, header, field_name):
361
361
print ('\n ==================================\n Creating %s API \n ==================================' % args .api )
362
362
if args .api == 'P4runtime' :
363
363
# import P4_api_grta as api
364
- print "This version doesn't support P4rt api"
364
+ print ( "This version doesn't support P4rt api" )
365
365
exit (1 )
366
366
if args .api == 'SDK' :
367
367
# import P4_api_SDK as api
368
- print "This version doesn't support SDK api"
368
+ print ( "This version doesn't support SDK api" )
369
369
exit (1 )
370
370
if args .api == 'SAI' :
371
371
import P4_api_SAI as api
0 commit comments