processes the filepath by checking if it is a directory or not
        and adding `.py` if not present.
516894
def _clean_filepath(self, filepath):
        
        if (os.path.isdir(filepath) and
                os.path.isfile(os.path.join(filepath, '__init__.py'))):

            filepath = os.path.join(filepath, '__init__.py')

        if (not filepath.endswith('.py') and
                os.path.isfile(filepath + '.py')):
            filepath += '.py'
        return filepath
271854
def load(filepath=None):
    
    if filepath and os.path.exists(filepath):
        pass
    else:
        if not os.path.exists('.env'):
            return False
        filepath = os.path.join('.env')

    for key, value in _get_line_(filepath):
        # set the key, value in the python environment vars dictionary
        # does not make modifications system wide.
        os.environ.setdefault(key, str(value))
    return True
486820
def _process_file(self, path):
        
        try:
            f = open(path)
            for line in f:
                self._process_line(line)

            os.remove(path)
        except IOError as ex:
            self.log.error("Could not open file `{path}': {error}".format(
                path=path, error=ex.strerror))
96067
def move_file_to_directory(file_path, directory_path):
        
        file_name = os.path.basename(file_path)  # get name of file
        if not os.path.exists(directory_path):
            os.makedirs(directory_path)  # create directory if necessary
        os.rename(file_path, os.path.join(directory_path,
                                          file_name))
748617
def assure_directory_exists(path, is_file=False):
    """"""
    if is_file:
        path = osp.dirname(path)
    # END handle file
    if not osp.isdir(path):
        os.makedirs(path)
        return True
    return False
1288831
def directory_is_present(self, directory_path):
        
        p = self.p(directory_path)
        if not os.path.exists(p):
            return False
        if not os.path.isdir(p):
            raise IOError("%s is not a directory" % directory_path)
        return True
942682
private void process(Path dir, Path file, WatchEvent.Kind<?> evtType) throws TTException, IOException,
        InterruptedException {
        // LOGGER.info("Processing " + file.getFileName() + " with event "
        // + evtType);
        IFilelistenerWriteTrx trx = null;
        String rootPath = getListenerRootPath(dir);

        String relativePath = file.toFile().getAbsolutePath();
        relativePath = relativePath.substring(getListenerRootPath(dir).length(), relativePath.length());

        for (Entry<String, String> e : mFilelistenerToPaths.entrySet()) {
            if (e.getValue().equals(getListenerRootPath(dir))) {
                trx = mTrx.get(e.getKey());
            }
        }

        if (file.toFile().isDirectory()) {
            if (evtType == ENTRY_CREATE) {
                addSubDirectory(dir, file);
                return;
            } else if (evtType == ENTRY_DELETE) {
                for (String s : trx.getFilePaths()) {
                    if (s.contains(relativePath)) {
                        trx.removeFile(s);
                    }
                }
            }
        } else {
            // if (mLockedFiles.get(rootPath + File.separator
            // + file.toFile().getName()) != null) {
            // if (mLockedFiles.get(
            // rootPath + File.separator + file.toFile().getName())
            // .isFinished()) {
            // ExecutorService s = mExecutorMap
            // .get(getListenerRootPath(dir));
            // if (s != null && !s.isShutdown()) {
            //
            // FilesystemNotification n = new FilesystemNotification(
            // file.toFile(), relativePath, rootPath, evtType,
            // trx);
            // if (mObserver != null) {
            // n.addObserver(mObserver);
            // }
            // mFsnOnHold.remove(rootPath + File.separator
            // + file.toFile().getName());
            // mLockedFiles.put(rootPath + File.separator
            // + file.toFile().getName(), n);
            // s.submit(n);
            // }
            // } else {
            // FilesystemNotification n = new FilesystemNotification(
            // file.toFile(), relativePath, rootPath, evtType, trx);
            // if (mObserver != null) {
            // n.addObserver(mObserver);
            // }
            // mFsnOnHold.put(rootPath + File.separator
            // + file.toFile().getName(), n);
            // }
            // } else {
            ExecutorService s = mExecutorMap.get(getListenerRootPath(dir));
            if (s != null && !s.isShutdown()) {
                FilesystemNotification n =
                    new FilesystemNotification(file.toFile(), relativePath, rootPath, evtType, trx);
                if (mObserver != null) {
                    n.addObserver(mObserver);
                }
                // mLockedFiles.put(rootPath + File.separator
                // + file.toFile().getName(), n);

                s.submit(n);
                // }
            }
        }

    }
1219937
def is_valid_dir(path):
    '''  '''
    return os.path.exists(path) and os.path.isdir(path)
61199
def is_installable_dir(path):
    # type: (str) -> bool
    
    if not os.path.isdir(path):
        return False
    setup_py = os.path.join(path, 'setup.py')
    if os.path.isfile(setup_py):
        return True
    pyproject_toml = os.path.join(path, 'pyproject.toml')
    if os.path.isfile(pyproject_toml):
        return True
    return False
635712
def _ensure_filepath(filename):
        

        filepath = os.path.dirname(filename)
        if not os.path.exists(filepath):
            os.makedirs(filepath)
396601
def make_directory_if_needed(directory_path):
    
    if os.path.exists(directory_path):
        if not os.path.isdir(directory_path):
            raise OSError("Path is not a directory:", directory_path)
    else:
        os.makedirs(directory_path)
275163
def check_path(self, path):
        
        path = os.path.abspath(path)
        if os.path.exists(path):
            return path
        else:
            utils.die("input file does not exists:\n  {}".format(path))
451582
def ensure_outdir_exists(filepath):
    
    outdir = os.path.dirname(filepath)

    if outdir and not os.path.exists(outdir):
        LOGGER.debug("Making output dir: %s", outdir)
        os.makedirs(outdir)
190583
function processSourceFile(work_directory, file_path) {

    var path = create('fs.path', work_directory).combine(file_path),
        source = create('fs.filereader(utf8)', path).readSync();

    // replace /*#include filename.ext*/
    var result = source.replace(/\/\*#include \S+\*\//gm, function(line) {
        var include_file_path = /\/\*#include (\S+)\*\//.exec(line)[1];
        // list .js file
        watch_list.push(include_file_path);
        // recursively perform substitutions
        return processSourceFile(path.getParentPath().path, include_file_path);
    });

    return result;
}
166520
def is_installable_dir(path):
    """"""
    if not os.path.isdir(path):
        return False
    setup_py = os.path.join(path, "setup.py")
    if os.path.isfile(setup_py):
        return True
    return False
177671
def ensure_directory(path):
    """"""
    dirname = os.path.dirname(path)
    py31compat.makedirs(dirname, exist_ok=True)
1041524
function isDirectory(filePath, callback) {
  try {
    fs.stat(filePath, function (err, data) {
      if (err) {
        callback(null, false);
      } else {
        callback(null, data.isDirectory());
      }
    });
  } catch (e) {
    callback(null, false);
  }
}