parameters: (filename)
docstring: Unzip filename to a temporary directory, set to the cwd.
  
      The unzipped target is cleaned up after.
docstring_summary: Unzip filename to a temporary directory, set to the cwd.
docstring_tokens: Unzip filename to a temporary directory set to the cwd .
function: def archive_context(filename):
      """
      Unzip filename to a temporary directory, set to the cwd.
  
      The unzipped target is cleaned up after.
      """
      tmpdir = tempfile.mkdtemp()
      log.warn('Extracting in %s', tmpdir)
      old_wd = os.getcwd()
      try:
          os.chdir(tmpdir)
          with ContextualZipFile(filename) as archive:
              archive.extractall()
  
          # going in the directory
          subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
          os.chdir(subdir)
          log.warn('Now working in %s', subdir)
          yield
  
      finally:
          os.chdir(old_wd)
          shutil.rmtree(tmpdir)
function_tokens: def archive_context ( filename ) : tmpdir = tempfile . mkdtemp ( ) log . warn ( 'Extracting in %s' , tmpdir ) old_wd = os . getcwd ( ) try : os . chdir ( tmpdir ) with ContextualZipFile ( filename ) as archive : archive . extractall ( ) # going in the directory subdir = os . path . join ( tmpdir , os . listdir ( tmpdir ) [ 0 ] ) os . chdir ( subdir ) log . warn ( 'Now working in %s' , subdir ) yield finally : os . chdir ( old_wd ) shutil . rmtree ( tmpdir )