Assert fail if current directory is different from location of the script
540108
def assert_script_in_current_directory():
  """"""

  script = sys.argv[0]
  assert os.path.abspath(os.path.dirname(script)) == os.path.abspath(
    '.'), f"Change into directory of script {script} and run again."
483157
def ensure_dir_exists(directory):
    ""
    if directory.startswith('gs://'):
        return
    if not os.path.exists(directory):
        dbg("Making dir {}".format(directory))
    os.makedirs(directory, exist_ok=True)
1345750
def O
      dir = current_item.directory? ? current_item.path : current_dir.path
      system %Q[osascript -e 'tell app "Terminal"
        do script "cd #{dir}"
      end tell'] if osx?
    end
1239747
def __is_outside_of_builddir(project, path_to_check):
    """"""
    bdir = project.builddir
    cprefix = os.path.commonprefix([path_to_check, bdir])
    return cprefix != bdir
701327
def verify_directory(dir):
    """"""

    tries = 0

    while not os.path.exists(dir):
        try:
            tries += 1
            os.makedirs(dir, compat.octal("0775"))
        except:
            if tries > 5:
                raise
432300
def isignored(self, relpath, directory=False):
    """"""
    relpath = self._relpath_no_dot(relpath)
    if directory:
      relpath = self._append_trailing_slash(relpath)
    return self.ignore.match_file(relpath)
746611
def check_local() -> None:
    
    to_check = ['./replay', './replay/toDo', './replay/archive']

    for i in to_check:
        if not os.path.exists(i):
            os.makedirs(i)
593687
def dir_exists(location, use_sudo=False):
    """"""
    with settings(hide('running', 'stdout', 'stderr'), warn_only=True):
        if use_sudo:
            # convert return code 0 to True
            return not bool(sudo('test -d %s' % (location)).return_code)
        else:
            return not bool(run('test -d %s' % (location)).return_code)
177671
def ensure_directory(path):
    """"""
    dirname = os.path.dirname(path)
    py31compat.makedirs(dirname, exist_ok=True)
680587
def _assert_path_is_dir(self, dir_path):
        
        if not os.path.isdir(dir_path):
            raise django.core.management.base.CommandError(
                'Invalid dir path. path="{}"'.format(dir_path)
            )
1347914
private static boolean isSavedInDir(ScriptWrapper scriptWrapper, File directory) {
		File file = scriptWrapper.getFile();
		if (file == null) {
			return false;
		}
		return file.getParentFile().equals(directory);
	}
727850
function isRealDirectory(p) {
    var stats;
    try {
        stats = fs.statSync(p);
    } catch (error) {
        // Not a valid path if stat fails.
        return false;
    }
    
    return (stats.isDirectory());
}
904167
function ensureDir(dir) {
        try {
            if (!fs_1.existsSync(dir))
                fs_1.mkdirSync(dir);
            return true;
        }
        catch (ex) {
            return false;
        }
    }
486975
function checkWorkingDir(workingDir, cb) {
  fs.stat(workingDir, function(err, stats) {
    var errMessage;
    if (err) {
      errMessage = "The directory " + workingDir + " does not exist.";
      logger.error(errMessage);
      return cb(errMessage);
    }

    //Checking that it is a directory
    if (!stats.isDirectory()) {
      errMessage = "Expected " + workingDir + " to be a directory";
      logger.error(errMessage);
      return cb(errMessage);
    }

    return cb();
  });
}
327707
function _isDirectory (directory, callback) {

			if ("undefined" === typeof directory) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof directory) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === directory.trim()) {
					throw new Error("\"directory\" argument is empty");
				}
			else if ("undefined" === typeof callback) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				lstat(directory, (err, stats) => {
					return callback(null, Boolean(!err && stats.isDirectory()));
				});

			}

		}
531963
def _assert_path_is_rw(self):
        
        if not self.path:
            raise ValueError("`path` argument must be set!")

        if not os.path.exists(self.path):
            raise IOError("`%s` not found." % self.path)

        if not os.path.isdir(self.path):
            raise IOError("`%s` is not a directory!" % self.path)

        if not os.access(self.path, (os.R_OK or os.W_OK)):
            raise IOError(
                "Can't access `%s`, please check permissions." % self.path
            )
33568
def ensure_dir_exists(path):
    """"""

    import os

    f_dir = os.path.dirname(path)

    if not os.path.exists(f_dir):
        os.makedirs(f_dir)

    return f_dir