def _create_hierarchies(metadata, levels, template):
 levels = object_dict(levels)
 hierarchies = []
 for md in metadata:
  if isinstance(md, compat.string_type):
   if (not template):
    raise ModelError('Can not specify just a hierarchy name ({}) if there is no template'.format(md))
   hier = template.hierarchy(md)
  else:
   md = dict(md)
   level_names = md.pop('levels')
   hier_levels = [levels[level] for level in level_names]
   hier = Hierarchy(levels=hier_levels, **md)
  hierarchies.append(hier)
 return hierarchies

def _create_hierarchies ( metadata , levels , template ) : levels = object_dict ( levels ) hierarchies = [ ] for md in metadata : if isinstance ( md , compat . string_type ) : if ( not template ) : raise ModelError ( 'Can not specify just a hierarchy name ({}) if there is no template' . format ( md ) ) hier = template . hierarchy ( md ) else : md = dict ( md ) level_names = md . pop ( 'levels' ) hier_levels = [ levels [ level ] for level in level_names ] hier = Hierarchy ( levels = hier_levels , ** md ) hierarchies . append ( hier ) return hierarchies
create dimension hierarchies from metadata and possibly inherit from template dimension .