Пример #1
0
    def _AddUriCacheTap(self):
        """Taps a resource Uri cache updater into self.resources if needed."""

        cache_update_op = self._command.GetUriCacheUpdateOp()
        if not cache_update_op:
            return

        if any([self._GetFlag(flag) for flag in self._CORRUPT_FLAGS]):
            return

        cacher = display_taps.UriCacher(cache_update_op, self._defaults)
        self._resources = peek_iterable.Tapper(self._resources, cacher.Tap,
                                               cacher.Done)
Пример #2
0
    def _AddUriCacheTap(self):
        """Taps a resource Uri cache updater into self.resources if needed."""

        if not self._info or self._info.bypass_cache:
            return

        cache_update_op = self._command.GetUriCacheUpdateOp()
        if not cache_update_op:
            return

        if any([self._GetFlag(flag) for flag in self._CORRUPT_FLAGS]):
            return

        tap = display_taps.UriCacher(cache_update_op, self._transform_uri)
        self._resources = peek_iterable.Tapper(self._resources, tap)
Пример #3
0
    def _AddUriCacheTap(self):
        """Taps a resource Uri cache updater into self.resources if needed."""

        from googlecloudsdk.calliope import base  # pylint: disable=g-import-not-at-top, circular dependency

        if self._cache_updater == cache_update_ops.NoCacheUpdater:
            return

        if not self._cache_updater:
            # pylint: disable=protected-access
            if not isinstance(self._command,
                              (base.CreateCommand, base.DeleteCommand,
                               base.ListCommand, base.RestoreCommand)):
                return
            if 'AddCacheUpdater' in properties.VALUES.core.lint.Get():
                # pylint: disable=protected-access
                raise CommandNeedsAddCacheUpdater(
                    '`{}` needs a parser.display_info.AddCacheUpdater() call.'.
                    format(' '.join(self._args._GetCommand().GetPath())))
            return

        if self._legacy and (not self._info or self._info.bypass_cache):
            return
        if any([self._GetFlag(flag) for flag in self._CORRUPT_FLAGS]):
            return

        # pylint: disable=protected-access
        if isinstance(self._command,
                      (base.CreateCommand, base.RestoreCommand)):
            cache_update_op = cache_update_ops.AddToCacheOp(
                self._cache_updater)
        elif isinstance(self._command, base.DeleteCommand):
            cache_update_op = cache_update_ops.DeleteFromCacheOp(
                self._cache_updater)
        elif isinstance(self._command, base.ListCommand):
            cache_update_op = cache_update_ops.ReplaceCacheOp(
                self._cache_updater)
        else:
            raise CommandShouldntHaveAddCacheUpdater(
                'Cache updater [{}] not expected for [{}] `{}`.'.format(
                    module_util.GetModulePath(self._cache_updater),
                    module_util.GetModulePath(self._args._GetCommand()),
                    ' '.join(self._args._GetCommand().GetPath())))

        tap = display_taps.UriCacher(cache_update_op, self._transform_uri)
        self._resources = peek_iterable.Tapper(self._resources, tap)