def _validate_dict(self, spec, data): accept_any_key = False any_key_spec = None for k in iterkeys(spec): if isinstance(k, required): if k not in data: self._handle_error("missing '%s', not in %s" % (k, self.context.current_pos)) if isinstance(k, anything): accept_any_key = True any_key_spec = spec[k] for k, v in iteritems(data): if accept_any_key: with self.context.pos('.' + text_type(k)): self._validate_part(any_key_spec, v) else: if k not in spec: self._handle_error("unknown '%s' in %s" % (k, self.context.current_pos), info_only=True) continue with self.context.pos('.' + text_type(k)): self._validate_part(spec[k], v)
def _grids(self, caches): grids = [] if 'grids' in self.conf: # grids available for all caches available_grids = reduce(operator.and_, (set(cache) for cache in caches.values())) for grid_name in self.conf['grids']: if grid_name not in available_grids: raise SeedConfigurationError('%s not defined for caches' % grid_name) grids.append(grid_name) else: # check that all caches have the same grids configured last = [] for cache_grids in (set(iterkeys(cache)) for cache in itervalues(caches)): if not last: last = cache_grids else: if last != cache_grids: raise SeedConfigurationError( 'caches in same seed task require identical grids') grids = list(last or []) return grids
def _grids(self, caches): grids = [] if 'grids' in self.conf: # grids available for all caches available_grids = reduce(operator.and_, (set(cache) for cache in caches.values())) for grid_name in self.conf['grids']: if grid_name not in available_grids: raise SeedConfigurationError('%s not defined for caches' % grid_name) grids.append(grid_name) else: # check that all caches have the same grids configured last = [] for cache_grids in (set(iterkeys(cache)) for cache in itervalues(caches)): if not last: last = cache_grids else: if last != cache_grids: raise SeedConfigurationError('caches in same seed task require identical grids') grids = list(last or []) return grids
def _validate_dict(self, spec, data): accept_any_key = False any_key_spec = None for k in iterkeys(spec): if isinstance(k, required): if k not in data: self._handle_error("missing '%s' not in %s" % (k, self.context.current_pos)) if isinstance(k, anything): accept_any_key = True any_key_spec = spec[k] for k, v in iteritems(data): if accept_any_key: with self.context.pos('.' + text_type(k)): self._validate_part(any_key_spec, v) else: if k not in spec: self._handle_error("unknown '%s' in %s" % (k, self.context.current_pos), info_only=True) continue with self.context.pos('.' + text_type(k)): self._validate_part(spec[k], v)
def __init__(self, layers): self.grids = [lyr.grid for lyr in layers.values()] self.layers = layers self._layer = layers[next(iterkeys(layers))]