def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
 if isinstance(data_source, six.string_types):
  data_source = DataSource(data_source)
 elif isinstance(data_source, DataSource):
  pass
 else:
  raise TypeError('Data source parameter must be a string or a DataSource object.')
 _mapping = {}
 for field in data_source[layer_key].fields:
  mfield = field.lower()
  if (mfield[(-1):] == '_'):
   mfield += 'field'
  _mapping[mfield] = field
 gtype = data_source[layer_key].geom_type
 if (multi_geom and (gtype.num in (1, 2, 3))):
  prefix = 'MULTI'
 else:
  prefix = ''
 _mapping[geom_name] = (prefix + str(gtype).upper())
 return _mapping

def mapping ( data_source , geom_name = 'geom' , layer_key = 0 , multi_geom = False ) : if isinstance ( data_source , six . string_types ) : data_source = DataSource ( data_source ) elif isinstance ( data_source , DataSource ) : pass else : raise TypeError ( 'Data source parameter must be a string or a DataSource object.' ) _mapping = { } for field in data_source [ layer_key ] . fields : mfield = field . lower ( ) if ( mfield [ ( - 1 ) : ] == '_' ) : mfield += 'field' _mapping [ mfield ] = field gtype = data_source [ layer_key ] . geom_type if ( multi_geom and ( gtype . num in ( 1 , 2 , 3 ) ) ) : prefix = 'MULTI' else : prefix = '' _mapping [ geom_name ] = ( prefix + str ( gtype ) . upper ( ) ) return _mapping
given a datasource .