def _do_create_artifact_cache(self, spec, action):
    """Returns an artifact cache for the specified spec.

    spec can be:
      - a path to a file-based cache root.
      - a URL of a RESTful cache root.
      - a bar-separated list of URLs, where we'll pick the one with the best ping times.
      - A list or tuple of two specs, local, then remote, each as described above
    """
    compression = self._options.compression_level
    if compression not in range(1, 10):
      raise ValueError('compression_level must be an integer 1-9: {}'.format(compression))

    artifact_root = self._options.pants_workdir

    def create_local_cache(parent_path):
      path = os.path.join(parent_path, self._cache_dirname)
      self._log.debug('{0} {1} local artifact cache at {2}'
                      .format(self._task.stable_name(), action, path))
      return LocalArtifactCache(artifact_root, path, compression,
                                self._options.max_entries_per_target,
                                permissions=self._options.write_permissions,
                                dereference=self._options.dereference_symlinks)

    def create_remote_cache(remote_spec, local_cache):
      urls = self.get_available_urls(remote_spec.split('|'))

      if len(urls) > 0:
        best_url_selector = BestUrlSelector(
          ['{}/{}'.format(url.rstrip('/'), self._cache_dirname) for url in urls]
        )
        local_cache = local_cache or TempLocalArtifactCache(artifact_root, compression)
        return RESTfulArtifactCache(
          artifact_root,
          best_url_selector,
          local_cache,
          read_timeout=self._options.read_timeout,
          write_timeout=self._options.write_timeout,
        )

    local_cache = create_local_cache(spec.local) if spec.local else None
    remote_cache = create_remote_cache(spec.remote, local_cache) if spec.remote else None
    if remote_cache:
      return remote_cache
    return local_cache
def _do_create_artifact_cache ( self , spec , action ) : compression = self . _options . compression_level if compression not in range ( 1 , 10 ) : raise ValueError ( 'compression_level must be an integer 1-9: {}' . format ( compression ) ) artifact_root = self . _options . pants_workdir def create_local_cache ( parent_path ) : path = os . path . join ( parent_path , self . _cache_dirname ) self . _log . debug ( '{0} {1} local artifact cache at {2}' . format ( self . _task . stable_name ( ) , action , path ) ) return LocalArtifactCache ( artifact_root , path , compression , self . _options . max_entries_per_target , permissions = self . _options . write_permissions , dereference = self . _options . dereference_symlinks ) def create_remote_cache ( remote_spec , local_cache ) : urls = self . get_available_urls ( remote_spec . split ( '|' ) ) if len ( urls ) > 0 : best_url_selector = BestUrlSelector ( [ '{}/{}' . format ( url . rstrip ( '/' ) , self . _cache_dirname ) for url in urls ] ) local_cache = local_cache or TempLocalArtifactCache ( artifact_root , compression ) return RESTfulArtifactCache ( artifact_root , best_url_selector , local_cache , read_timeout = self . _options . read_timeout , write_timeout = self . _options . write_timeout , ) local_cache = create_local_cache ( spec . local ) if spec . local else None remote_cache = create_remote_cache ( spec . remote , local_cache ) if spec . remote else None if remote_cache : return remote_cache return local_cache
Returns an artifact cache for the specified spec.

    spec can be:
      - a path to a file-based cache root.
      - a URL of a RESTful cache root.
      - a bar-separated list of URLs, where we'll pick the one with the best ping times.
      - A list or tuple of two specs, local, then remote, each as described above