parameters: (path)
return_statement: return path
docstring: Needed because os.path.join() discards the first path if the
      second one is absolute, which is usually the case here. Still, we
      want relative paths to work and leverage the os awareness of
      os.path.join().
docstring_summary: Needed because os.path.join() discards the first path if the
      second one is absolute, which is usually the case here. Still, we
      want relative paths to work and leverage the os awareness of
      os.path.join().
docstring_tokens: Needed because os . path . join () discards the first path if the second one is absolute which is usually the case here . Still we want relative paths to work and leverage the os awareness of os . path . join () .
function: def prepend_destdir(path):
      """
      Needed because os.path.join() discards the first path if the
      second one is absolute, which is usually the case here. Still, we
      want relative paths to work and leverage the os awareness of
      os.path.join().
      """
      destdir = os.environ.get('DESTDIR', "")
  
      if destdir:
          # DESTDIR is non-empty, but we only join absolute paths on UNIX-like file systems
          if os.path.sep != "/":
              raise PrependDestdirError("Only UNIX-like file systems using forward slash " \
                                        "separator supported when DESTDIR is set.")
          if not os.path.isabs(path):
              raise PrependDestdirError("--prefix must be an absolute path when DESTDIR is set.")
  
          path = os.path.normpath(path)
          # Remove / or \ prefixes if existent to accomodate for os.path.join()
          path = path.lstrip(os.path.sep)
          path = os.path.join(destdir, path)
  
          if not is_subdir(destdir, path):
              raise PrependDestdirError("path escapes DESTDIR (path='%s', destdir='%s')" % (path, destdir))
  
      return path
function_tokens: def prepend_destdir ( path ) : destdir = os . environ . get ( 'DESTDIR' , "" ) if destdir : # DESTDIR is non-empty, but we only join absolute paths on UNIX-like file systems if os . path . sep != "/" : raise PrependDestdirError ( "Only UNIX-like file systems using forward slash " "separator supported when DESTDIR is set." ) if not os . path . isabs ( path ) : raise PrependDestdirError ( "--prefix must be an absolute path when DESTDIR is set." ) path = os . path . normpath ( path ) # Remove / or \ prefixes if existent to accomodate for os.path.join() path = path . lstrip ( os . path . sep ) path = os . path . join ( destdir , path ) if not is_subdir ( destdir , path ) : raise PrependDestdirError ( "path escapes DESTDIR (path='%s', destdir='%s')" % ( path , destdir ) ) return path