def expand_level_metadata(metadata):
 if isinstance(metadata, compat.string_type):
  metadata = {'name': metadata, 'attributes': [metadata]}
 else:
  metadata = dict(metadata)
 try:
  name = metadata['name']
 except KeyError:
  raise ModelError('Level has no name')
 attributes = metadata.get('attributes')
 if (not attributes):
  attribute = {'name': name, 'label': metadata.get('label')}
  attributes = [attribute]
 metadata['attributes'] = [expand_attribute_metadata(a) for a in attributes]
 if ('cardinality' not in metadata):
  info = metadata.get('info', {})
  if ('high_cardinality' in info):
   metadata['cardinality'] = 'high'
 return metadata

def expand_level_metadata ( metadata ) : if isinstance ( metadata , compat . string_type ) : metadata = { 'name' : metadata , 'attributes' : [ metadata ] } else : metadata = dict ( metadata ) try : name = metadata [ 'name' ] except KeyError : raise ModelError ( 'Level has no name' ) attributes = metadata . get ( 'attributes' ) if ( not attributes ) : attribute = { 'name' : name , 'label' : metadata . get ( 'label' ) } attributes = [ attribute ] metadata [ 'attributes' ] = [ expand_attribute_metadata ( a ) for a in attributes ] if ( 'cardinality' not in metadata ) : info = metadata . get ( 'info' , { } ) if ( 'high_cardinality' in info ) : metadata [ 'cardinality' ] = 'high' return metadata
returns a level description as a dictionary .