'See citadel.py::ImportHandler.find_importables_in_dir() for
details.
Importables for JavaScript look like this:
{"foo.js":  ("foo.js", None, False),
"somedir": (None,     None, True)}
TODO: log the fs-stat\'ing a la codeintel.db logging.'

def find_importables_in_dir(self, dir):

    from os.path import join, isdir, splitext
    if (dir == '<Unsaved>'):
        return {}
    try:
        names = os.listdir(dir)
    except OSError as ex:
        return {}
    (dirs, nondirs) = (set(), set())
    for name in names:
        try:
            if isdir(join(dir, name)):
                dirs.add(name)
            else:
                nondirs.add(name)
        except UnicodeDecodeError:
            pass
    importables = {}
    for name in nondirs:
        (base, ext) = splitext(name)
        if ((not name.endswith(self.import_file_extensions)) or name.endswith(self.ignore_file_extensions)):
            continue
        if (base in dirs):
            importables[base] = (name, None, True)
            dirs.remove(base)
        else:
            importables[base] = (name, None, False)
    for name in dirs:
        importables[name] = (None, None, True)
    return importables
