def save_objects_to_file(file_name, data_dict):
 if (file_name.count('.') == 1):
  (_, out_format) = file_name.split('.')
 else:
  raise ValueError('Invalid file name: {0}'.format(file_name))
 if (out_format == 'pkl'):
  with open(file_name, 'w') as f:
   pickle.dump(data_dict, f)
 elif (out_format == 'yml'):
  with open(file_name, 'w') as f:
   f.write(yaml.dump(data_dict, default_flow_style=False))
 elif (out_format == 'json'):
  with open(file_name, 'w') as f:
   json.dump(data_dict, f)

def save_objects_to_file ( file_name , data_dict ) : if ( file_name . count ( '.' ) == 1 ) : ( _ , out_format ) = file_name . split ( '.' ) else : raise ValueError ( 'Invalid file name: {0}' . format ( file_name ) ) if ( out_format == 'pkl' ) : with open ( file_name , 'w' ) as f : pickle . dump ( data_dict , f ) elif ( out_format == 'yml' ) : with open ( file_name , 'w' ) as f : f . write ( yaml . dump ( data_dict , default_flow_style = False ) ) elif ( out_format == 'json' ) : with open ( file_name , 'w' ) as f : json . dump ( data_dict , f )
write the network devices out to a file .