def expand_cube_metadata(metadata):
 metadata = dict(metadata)
 if (not ('name' in metadata)):
  raise ModelError('Cube has no name')
 links = metadata.get('dimensions', [])
 if links:
  links = expand_dimension_links(metadata['dimensions'])
 if ('hierarchies' in metadata):
  dim_hiers = dict(metadata['hierarchies'])
  for link in links:
   try:
    hiers = dim_hiers.pop(link['name'])
   except KeyError:
    continue
   link['hierarchies'] = hiers
  if dim_hiers:
   raise ModelError(('There are hierarchies specified for non-linked dimensions: %s.' % dim_hiers.keys()))
 nonadditive = metadata.pop('nonadditive', None)
 if ('measures' in metadata):
  measures = []
  for attr in metadata['measures']:
   attr = expand_attribute_metadata(attr)
   if nonadditive:
    attr['nonadditive'] = attr.get('nonadditive', nonadditive)
   measures.append(attr)
  metadata['measures'] = measures
 if links:
  metadata['dimensions'] = links
 return metadata

def expand_cube_metadata ( metadata ) : metadata = dict ( metadata ) if ( not ( 'name' in metadata ) ) : raise ModelError ( 'Cube has no name' ) links = metadata . get ( 'dimensions' , [ ] ) if links : links = expand_dimension_links ( metadata [ 'dimensions' ] ) if ( 'hierarchies' in metadata ) : dim_hiers = dict ( metadata [ 'hierarchies' ] ) for link in links : try : hiers = dim_hiers . pop ( link [ 'name' ] ) except KeyError : continue link [ 'hierarchies' ] = hiers if dim_hiers : raise ModelError ( ( 'There are hierarchies specified for non-linked dimensions: %s.' % dim_hiers . keys ( ) ) ) nonadditive = metadata . pop ( 'nonadditive' , None ) if ( 'measures' in metadata ) : measures = [ ] for attr in metadata [ 'measures' ] : attr = expand_attribute_metadata ( attr ) if nonadditive : attr [ 'nonadditive' ] = attr . get ( 'nonadditive' , nonadditive ) measures . append ( attr ) metadata [ 'measures' ] = measures if links : metadata [ 'dimensions' ] = links return metadata
expands metadata to be as complete as possible cube metadata .