cubes_lite/model/reader.py
def read_bundle(self, path):
        """Load logical model a directory specified by `path`.  Returns a model
        description dictionary. Model directory bundle has structure:

        * ``store.model/``
            * ``model.json``
            * ``cube1/``
                * ``cube.json``
                * ``dim_*.json``
            * ``cube2/``
                * ``cube.json``
                * ``dim_*.json``
        """

        assert os.path.isdir(path), 'Path "%s" is not a directory.'

        info_path = os.path.join(path, self.model_entry_file)
        if not os.path.exists(info_path) or not os.path.isfile(info_path):
            raise ModelError(
                'Main model info "%s" does not exist'.format(info_path)
            )

        model = self.load_json(info_path)
        self.validate_schema(self.model_schema, model)

        cube_names = model['cubes']
        model['cubes'] = []
        for cube in cube_names:
            cube_path = os.path.join(path, cube)
            info_path = os.path.join(cube_path, self.cube_entry_file)

            if not os.path.exists(cube_path):
                cube_path = path
                info_path = os.path.join(
                    cube_path,
                    self.cube_entry_file_simplified.format(name=cube),
                )

            if not (os.path.exists(info_path) and os.path.isfile(info_path)):
                raise ModelError(
                    'Bad cube entry file: "{}"'.format(info_path)
                )

            cube_model = self.load_json(info_path)
            self.validate_schema(self.cube_schema, cube_model)
            model['cubes'].append(cube_model)

            dimension_names = cube_model['dimensions']
            cube_model['dimensions'] = []
            for dimension in dimension_names:
                if not isinstance(dimension, compat.string_type):
                    continue

                info_path = os.path.join(
                    cube_path,
                    self.dimension_entry_file.format(name=dimension),
                )
                if not (os.path.exists(info_path) and os.path.isfile(info_path)):
                    # plain dimension doesn't require a file description
                    dimension_model = dimension
                else:
                    dimension_model = self.load_json(info_path)
                    self.validate_schema(self.dimension_schema, dimension_model)

                cube_model['dimensions'].append(dimension_model)
            continue

        return model
Load logical model a directory specified by `path`.  Returns a model
        description dictionary. Model directory bundle has structure:

        * ``store.model/``
            * ``model.json``
            * ``cube1/``
                * ``cube.json``
                * ``dim_*.json``
            * ``cube2/``
                * ``cube.json``
                * ``dim_*.json``
        
Load logical model a directory specified by `path`.  Returns a model
description dictionary. Model directory bundle has structure.


Load logical model a directory specified by ` path ` . Returns a model description dictionary . Model directory bundle has structure .
def read_bundle(self, path):
        assert os.path.isdir(path), 'Path "%s" is not a directory.'
        info_path = os.path.join(path, self.model_entry_file)
        if not os.path.exists(info_path) or not os.path.isfile(info_path):
            raise ModelError(
                'Main model info "%s" does not exist'.format(info_path)
            )
        model = self.load_json(info_path)
        self.validate_schema(self.model_schema, model)
        cube_names = model['cubes']
        model['cubes'] = []
        for cube in cube_names:
            cube_path = os.path.join(path, cube)
            info_path = os.path.join(cube_path, self.cube_entry_file)
            if not os.path.exists(cube_path):
                cube_path = path
                info_path = os.path.join(
                    cube_path,
                    self.cube_entry_file_simplified.format(name=cube),
                )
            if not (os.path.exists(info_path) and os.path.isfile(info_path)):
                raise ModelError(
                    'Bad cube entry file: "{}"'.format(info_path)
                )
            cube_model = self.load_json(info_path)
            self.validate_schema(self.cube_schema, cube_model)
            model['cubes'].append(cube_model)
            dimension_names = cube_model['dimensions']
            cube_model['dimensions'] = []
            for dimension in dimension_names:
                if not isinstance(dimension, compat.string_type):
                    continue
                info_path = os.path.join(
                    cube_path,
                    self.dimension_entry_file.format(name=dimension),
                )
                if not (os.path.exists(info_path) and os.path.isfile(info_path)):
                    dimension_model = dimension
                else:
                    dimension_model = self.load_json(info_path)
                    self.validate_schema(self.dimension_schema, dimension_model)
                cube_model['dimensions'].append(dimension_model)
            continue
        return model
def read_bundle ( self , path ) : assert os . path . isdir ( path ) , 'Path "%s" is not a directory.' info_path = os . path . join ( path , self . model_entry_file ) if not os . path . exists ( info_path ) or not os . path . isfile ( info_path ) : raise ModelError ( 'Main model info "%s" does not exist' . format ( info_path ) ) model = self . load_json ( info_path ) self . validate_schema ( self . model_schema , model ) cube_names = model [ 'cubes' ] model [ 'cubes' ] = [ ] for cube in cube_names : cube_path = os . path . join ( path , cube ) info_path = os . path . join ( cube_path , self . cube_entry_file ) if not os . path . exists ( cube_path ) : cube_path = path info_path = os . path . join ( cube_path , self . cube_entry_file_simplified . format ( name = cube ) , ) if not ( os . path . exists ( info_path ) and os . path . isfile ( info_path ) ) : raise ModelError ( 'Bad cube entry file: "{}"' . format ( info_path ) ) cube_model = self . load_json ( info_path ) self . validate_schema ( self . cube_schema , cube_model ) model [ 'cubes' ] . append ( cube_model ) dimension_names = cube_model [ 'dimensions' ] cube_model [ 'dimensions' ] = [ ] for dimension in dimension_names : if not isinstance ( dimension , compat . string_type ) : continue info_path = os . path . join ( cube_path , self . dimension_entry_file . format ( name = dimension ) , ) if not ( os . path . exists ( info_path ) and os . path . isfile ( info_path ) ) : dimension_model = dimension else : dimension_model = self . load_json ( info_path ) self . validate_schema ( self . dimension_schema , dimension_model ) cube_model [ 'dimensions' ] . append ( dimension_model ) continue return model
Load logical model a directory specified by `path`.
Load logical model a directory specified by ` path ` .
"""Load logical model a directory specified by `path`.  Returns a model
        description dictionary. Model directory bundle has structure:

        * ``store.model/``
            * ``model.json``
            * ``cube1/``
                * ``cube.json``
                * ``dim_*.json``
            * ``cube2/``
                * ``cube.json``
                * ``dim_*.json``
        """ # plain dimension doesn't require a file description
self
path