def _parse_schema_resource(info):
 if ('fields' not in info):
  return None
 schema = []
 for r_field in info['fields']:
  name = r_field['name']
  field_type = r_field['type']
  mode = r_field.get('mode', 'NULLABLE')
  description = r_field.get('description')
  sub_fields = _parse_schema_resource(r_field)
  schema.append(SchemaField(name, field_type, mode, description, sub_fields))
 return schema

def _parse_schema_resource ( info ) : if ( 'fields' not in info ) : return None schema = [ ] for r_field in info [ 'fields' ] : name = r_field [ 'name' ] field_type = r_field [ 'type' ] mode = r_field . get ( 'mode' , 'NULLABLE' ) description = r_field . get ( 'description' ) sub_fields = _parse_schema_resource ( r_field ) schema . append ( SchemaField ( name , field_type , mode , description , sub_fields ) ) return schema
parse a resource fragment into a schema field .