class_docstr: Cache to maintain extracted archives
  
  Parameters
  ----------
  toppath : str
    Top directory under .git/ of which temp directory would be created.
    If not provided -- random tempdir is used
  persistent : bool, optional
    Passed over into generated ExtractedArchives
class_docstr_tok: ["Cache","to","maintain","extracted","archives","Parameters","--","--","--","--","--","toppath",":","str","Top","directory","under",".git\/","of","which","temp","directory","would","be","created",".","If","not","provided","--","random","tempdir","is","used","persistent",":","bool",",","optional","Passed","over","into","generated","ExtractedArchives"]
code: def __init__(self, toppath=None, persistent=False):
      self._toppath = toppath
      if toppath:
          path = opj(toppath, ARCHIVES_TEMP_DIR)
          if not persistent:
              tempsuffix = "-" + _get_random_id()
              lgr.debug(
                  "For non-persistent archives using %s suffix for path %s",
                  tempsuffix,
                  path,
              )
              path += tempsuffix
          # TODO: begging for a race condition
          if not exists(path):
              lgr.debug(
                  "Initiating clean cache for the archives under %s",
                  path,
              )
              try:
                  self._made_path = True
                  os.makedirs(path)
                  lgr.debug("Cache initialized")
              except Exception:
                  lgr.error(
                      "Failed to initialize cached under %s", path
                  )
                  raise
          else:
              lgr.debug(
                  "Not initiating existing cache for the archives under %s",
                  path,
              )
              self._made_path = False
      else:
          if persistent:
              raise ValueError(
                  "%s cannot be persistent, because no toppath was provided"
                  % self
              )
          path = tempfile.mkdtemp(**get_tempfile_kwargs())
          self._made_path = True
  
      self._path = path
      self.persistent = persistent
      # TODO?  ensure that it is absent or we should allow for it to persist a bit?
      # if exists(path):
      #    self._clean_cache()
      self._archives = {}
  
      # TODO: begging for a race condition
      if not exists(path):
          lgr.debug(
              "Initiating clean cache for the archives under %s",
              self.path,
          )
          try:
              self._made_path = True
              os.makedirs(path)
              lgr.debug("Cache initialized")
          except Exception as e:
              lgr.error("Failed to initialize cached under %s", path)
              raise
      else:
          lgr.debug(
              "Not initiating existing cache for the archives under %s",
              self.path,
          )
          self._made_path = False
  
imports: import hashlib
  import logging
  import os
  import random
  import string
  import tempfile
  from datalad import cfg
  from datalad.config import anything2bool
  from datalad.consts import ARCHIVES_TEMP_DIR
  from datalad.support.external_versions import external_versions
  from datalad.support.locking import lock_if_check_fails
  from datalad.support.path import abspath, exists, isabs, isdir
  from datalad.support.path import join
  from datalad.support.path import normpath, pardir, relpath
  from datalad.support.path import sep
  from datalad.utils import Path, any_re_search, ensure_bytes, ensure_unicode, get_tempfile_kwargs, on_windows, rmtemp, rmtree, unlink
label_desc: Use image node_id 1 to create a new ArchivesCache object from inherited base classes: object with example: obj = ArchivesCache(toppath, persistent)