cubes_lite/model/dimension.py
def expand_model(cls, model_data):
        """
        Expands `model_data` to be as complete as possible dimension model.
        """

        if isinstance(model_data, compat.string_type):
            model_data = {
                'name': model_data,
                'levels': [model_data],
            }
        else:
            model_data = dict(model_data)

        if not 'name' in model_data:
            raise ModelError('Dimension has no name')

        name = model_data['name']

        # Fix levels
        levels = model_data.get('levels', [])
        if not levels:
            # Default: if no attributes, then there is single flat attribute
            # whith same name as the dimension
            level = {'name': name}

            for attr in ('attributes', 'key', 'order_attribute', 'order'):
                if attr in model_data:
                    level[attr] = model_data[attr]

            levels = [level]

        if levels:
            levels = [Level.expand_model(level) for level in levels]
            model_data['levels'] = levels

        return model_data

        Expands `model_data` to be as complete as possible dimension model.
        
Expands `model_data` to be as complete as possible dimension model.
Expands ` model_data ` to be as complete as possible dimension model .
def expand_model(cls, model_data):
        if isinstance(model_data, compat.string_type):
            model_data = {
                'name': model_data,
                'levels': [model_data],
            }
        else:
            model_data = dict(model_data)
        if not 'name' in model_data:
            raise ModelError('Dimension has no name')
        name = model_data['name']
        levels = model_data.get('levels', [])
        if not levels:
            level = {'name': name}
            for attr in ('attributes', 'key', 'order_attribute', 'order'):
                if attr in model_data:
                    level[attr] = model_data[attr]
            levels = [level]
        if levels:
            levels = [Level.expand_model(level) for level in levels]
            model_data['levels'] = levels
        return model_data
def expand_model ( cls , model_data ) : if isinstance ( model_data , compat . string_type ) : model_data = { 'name' : model_data , 'levels' : [ model_data ] , } else : model_data = dict ( model_data ) if not 'name' in model_data : raise ModelError ( 'Dimension has no name' ) name = model_data [ 'name' ] levels = model_data . get ( 'levels' , [ ] ) if not levels : level = { 'name' : name } for attr in ( 'attributes' , 'key' , 'order_attribute' , 'order' ) : if attr in model_data : level [ attr ] = model_data [ attr ] levels = [ level ] if levels : levels = [ Level . expand_model ( level ) for level in levels ] model_data [ 'levels' ] = levels return model_data
Expands `model_data` to be as complete as possible dimension model.
Expands ` model_data ` to be as complete as possible dimension model .
"""
        Expands `model_data` to be as complete as possible dimension model.
        """ # Fix levels # Default: if no attributes, then there is single flat attribute # whith same name as the dimension
cls
model_data