Exemplo n.º 1
0
    def _validate_tile_config(cls, tile_config):
        if 'tw_type' in tile_config and tilewidgets.get_tilewidget_class(tile_config['tw_type']) is None:
            raise ValueError('Invalid tw_type %r' % tile_config['tw_type'])

        if len(tile_config.get('tags', [])) > mqeconfig.MAX_TAGS or \
            'tile_options' in tile_config and len(tile_config['tile_options'].get('tags', []))\
                        > mqeconfig.MAX_TAGS:
            raise ValueError('Too many tags specified')

        for ss in tile_config.get('series_spec_list', []):
            if not isinstance(ss, dataseries.SeriesSpec):
                raise ValueError('series_spec_list must be a list of SeriesSpec objects')

        tile_options = tile_config.get('tile_options')
        if tile_options:

            if tile_options.get('sscs'):
                if not isinstance(tile_options['sscs'], dataseries.SeriesSpec):
                    raise ValueError('sscs must a SeriesSpec object')

            if tile_options.get('tpcreator_uispec'):
                if not isinstance(tile_options['tpcreator_uispec'], list):
                    raise ValueError('tpcreator_uispec must be a list')
                for d in tile_options['tpcreator_uispec']:
                    if not isinstance(d, dict):
                        raise ValueError('Each element of tpcreator_uispec must be a dict')
                    if not 'tag' in d or not 'prefix' in d:
                        raise ValueError('tpcreator_uispec dict must have "tag" and "prefix" keys')
                    if not all(isinstance(v, basestring) for v in d.values()):
                        raise ValueError('tpcreator_uispec dict values must be strings')
                    if not d['tag'].startswith(d['prefix']):
                        raise ValueError('tpcreator_uispec\'s tag %r doesn\'t start with prefix %r' %
                                         (d['tag'], d['prefix']))
Exemplo n.º 2
0
 def tilewidget(self):
     """The :class:`~mqe.tilewidgets.Tilewidget` of this tile"""
     tilewidget_class = tilewidgets.get_tilewidget_class(
         self.tile_options['tw_type'])
     if tilewidget_class is None:
         raise ValueError('Invalid tw_type %r' %
                          self.tile_options['tw_type'])
     return tilewidget_class(self)