'See citadel.py::ImportHandler.find_importables_in_dir() for
details.
Importables for Perl look like this:
{"Shell": ("Shell.pm", None, False),
"LWP":   ("LWP.pm",   None, True),
"XML":   (None,       None, True)}
Notes:
- Drop the "auto" dir (it holds the binary module bits).
- Keep non-capitalized dirs and modules (e.g. want "strict" in
cplns for "use <|>").'

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:
        if isdir(join(dir, name)):
            dirs.add(name)
        else:
            nondirs.add(name)
    importables = {}
    dirs.discard('auto')
    for name in nondirs:
        (base, ext) = splitext(name)
        if (ext != '.pm'):
            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
