Check that the destination dir isn't the source dir or a directory
 parent to the source dir.
516125
def ensure_not_in_dest
      dest_pathname = Pathname.new(dest)
      Pathname.new(source).ascend do |path|
        if path == dest_pathname
          raise(
            Errors::FatalException,
            "Destination directory cannot be or contain the Source directory."
          )
        end
      end
    end
519965
def go_to_parent_directory(self):
        """"""
        self.chdir(osp.abspath(osp.join(getcwd_or_home(), os.pardir)))
584365
function isInsideDir(dir, targetDir) {
  if (targetDir == dir) return false
  if (targetDir == '.') return dir
  const relative = path.relative(targetDir, dir)
  if (/^\.\./.test(relative)) return false
  return relative
}
108592
def check_dir(directory, newly_created_files):
  """"""
  header_parse_failures = []
  for root, dirs, files in os.walk(directory):
    for f in files:
      if f.endswith('.py') and os.path.basename(f) != '__init__.py':
        filename = os.path.join(root, f)
        try:
          check_header(filename, filename in newly_created_files)
        except HeaderCheckFailure as e:
          header_parse_failures.append(e.message)
  return header_parse_failures
145073
def isdir(self, relpath, rsc=None):
        
        filepath = self.find(relpath, rsc)
        if filepath.startswith(':'):
            resource = QtCore.QResource(filepath)
            return not resource.isFile()
        else:
            return os.path.isdir(filepath)
1283654
def path_is_inside(path, dirname):
    """"""
    path = os.path.abspath(path)
    dirname = os.path.abspath(dirname)
    while len(path) >= len(dirname):
        if path == dirname:
            return True
        newpath = os.path.dirname(path)
        if newpath == path:
            return False
        path = newpath
    return False
1120709
def _is_dirty(dir_path):
    """"""
    try:
        subprocess.check_call(["git", "diff", "--quiet"], cwd=dir_path)
        return False
    except subprocess.CalledProcessError:
        return True
551496
def specific_path_check(path, opt):
    """"""
    if opt.exclude:
        if path in opt.exclude:
            return False

    if opt.include:
        if path not in opt.include:
            return False

    return True
374424
function isSrcSubdir (src, dest) {
  try {
    return fs.statSync(src).isDirectory() &&
           src !== dest &&
           dest.indexOf(src) > -1 &&
           dest.split(path.dirname(src) + path.sep)[1].split(path.sep)[0] === path.basename(src)
  } catch (e) {
    return false
  }
}
846949
def is_dir(value):
    
    value = os.path.expanduser(value)
    value = os.path.expandvars(value)
    value = os.path.abspath(value)

    if os.path.exists(value):
        if os.path.isdir(value):
            if os.access(value, os.R_OK):
                return value

            else:
                err_message = ('{path}: Permission denied.'
                               ''.format(path=value)
                               )
                raise validate.VdtValueError(err_message)
        else:
            err_message = ('{value} is file.'
                           ''.format(value=value)
                           )
            raise validate.VdtTypeError(err_message)
    else:
        err_message = ('{path}: No such file or directory.'
                       ''.format(path=value)
                       )
        raise validate.VdtValueError(err_message)
1222308
def is_dir(self, pathobj):
        
        try:
            stat = self.stat(pathobj)

            return stat.is_dir
        except OSError as exc:
            if exc.errno != errno.ENOENT:
                raise
            return False
1332797
def _ensure_dir_exists(path):
    """"""
    if not op.exists(path):
        os.makedirs(path)
    assert op.exists(path) and op.isdir(path)
161172
def is_base_dir(d):
    ''''''
    if not dir_param_valid(d): # pragma: no cover
        raise 
    else:
        mfn = os.path.join(d,'s2') #marker name. it must be a directory.
        return os.path.isdir(mfn)
922267
def contains_parent_dir(fpath, dirs):
    
    # Note: this function is used nowhere in pygccxml but is used
    # at least by pypluplus; so it should stay here.

    return bool([x for x in dirs if _f(fpath, x)])
856014
def isdir(self, relpath):
    """"""
    if self._isdir_raw(relpath):
      if not self.isignored(relpath, directory=True):
        return True

    return False
510067
def _get_parent(self):
        """"""
        _dir = os.path.dirname(self.path)
        if is_repo(_dir):
            return Local(_dir)
        else:
            return None
317354
def ensure_dir_does_not_exist(*args):
    """"""
    path = os.path.join(*args)
    if os.path.isdir(path):
        shutil.rmtree(path)