class_docstr: ArrowSources is a companion class representing a directory containing
  Apache Arrow's sources.
class_docstr_tok: ["ArrowSources","is","a","companion","class","representing","a","directory","containing","Apache","Arrow","'s","sources","."]
docstr: Saves a git archive at path. 
docstr_tok: ["Saves","a","git","archive","at","path","."]
code: def archive(
      self, path, dereference=False, compressor=None, revision=None
  ):
      """Saves a git archive at path."""
      if not self.git_backed:
          raise ValueError("{} is not backed by git".format(self))
  
      rev = revision if revision else "HEAD"
      archive = git.archive(
          "--prefix=apache-arrow.tmp/", rev, git_dir=self.path
      )
      with tempfile.TemporaryDirectory() as tmp:
          tmp = Path(tmp)
          tar_path = tmp / "apache-arrow.tar"
          with open(tar_path, "wb") as tar:
              tar.write(archive)
          Command("tar").run("xf", tar_path, "-C", tmp)
          # Must use the same logic in dev/release/02-source.sh
          Command("cp").run(
              "-R", "-L", tmp / "apache-arrow.tmp", tmp / "apache-arrow"
          )
          Command("tar").run("cf", tar_path, "-C", tmp, "apache-arrow")
          with open(tar_path, "rb") as tar:
              archive = tar.read()
  
      if compressor:
          archive = compressor(archive)
  
      with open(path, "wb") as archive_fd:
          archive_fd.write(archive)
  
imports: import os
  from pathlib import Path
  import subprocess
  import tempfile
  from .command import Command
  from .git import git
label_desc: Use image node_id 11 for calling the ArrowSources obj's underlying member method code with example usage: obj.archive(path, dereference, compressor, revision) without return types