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: Infer Arrow sources directory from various method.
  
  The following guesses are done in order until a valid match is found:
  
  1. Checks the given optional parameter.
  
  2. Checks if the environment variable `ARROW_SRC` is defined and use
     this.
  
  3. Checks if the current working directory (cwd) is an Arrow source
     directory.
  
  4. Checks if this file (cli.py) is still in the original source
     repository. If so, returns the relative path to the source
     directory.
docstr_tok: ["Infer","Arrow","sources","directory","from","various","method",".","The","following","guesses","are","done","in","order","until","a","valid","match","is","found",":","1",".","Checks","the","given","optional","parameter",".","2",".","Checks","if","the","environment","variable","`","ARROW_SRC","`","is","defined","and","use","this",".","3",".","Checks","if","the","current","working","directory","(","cwd",")","is","an","Arrow","source","directory",".","4",".","Checks","if","this","file","(","cli.py",")","is","still","in","the","original","source","repository",".","If","so",",","returns","the","relative","path","to","the","source","directory","."]
code: def find(path=None):
      """Infer Arrow sources directory from various method.
  
      The following guesses are done in order until a valid match is found:
  
      1. Checks the given optional parameter.
  
      2. Checks if the environment variable `ARROW_SRC` is defined and use
         this.
  
      3. Checks if the current working directory (cwd) is an Arrow source
         directory.
  
      4. Checks if this file (cli.py) is still in the original source
         repository. If so, returns the relative path to the source
         directory.
      """
  
      # Explicit via environment
      env = os.environ.get("ARROW_SRC")
  
      # Implicit via cwd
      cwd = Path.cwd()
  
      # Implicit via current file
      try:
          this = Path(__file__).parents[4]
      except IndexError:
          this = None
  
      # Implicit via git repository (if archery is installed system wide)
      try:
          repo = git.repository_root(git_dir=cwd)
      except subprocess.CalledProcessError:
          # We're not inside a git repository.
          repo = None
  
      paths = list(filter(None, [path, env, cwd, this, repo]))
      for p in paths:
          try:
              return ArrowSources(p)
          except InvalidArrowSource:
              pass
  
      searched_paths = "\n".join([" - {}".format(p) for p in paths])
      raise InvalidArrowSource(
          "Unable to locate Arrow's source directory. "
          "Searched paths are:\n{}".format(searched_paths)
      )
  
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 13 for calling the ArrowSources obj's underlying member method code with example usage: obj.find(path) and returns: ArrowSources