'See citadel.py::ImportHandler.find_importables_in_dir() for
details.
Importables for Python look like this:
{"foo":    ("foo.py",             None,       False),
"foolib": ("foolib/__init__.py", "__init__", False),
"bar":    ("bar.pyc",            None,       False),
"baz":    ("baz.pyo",            None,       False),
"qoox":   ("qoox.pyd",           None,       False),
"qooz":   ("qooz.so",            None,       False),
Note: .pyd are .so handling depends on the platform.
If several files happen to have the same name but different
suffixes, the one with preferred suffix wins. The suffixe preference
is defined by the order of elements in the sequence generated
by _gen_suffixes().
This particularly means that sources always win over binaries.'

def find_importables_in_dir(self, imp_dir):

    if (imp_dir == '<Unsaved>'):
        return {}
    importables = {}
    if os.path.isdir(imp_dir):
        suffixes = dict(((s, i) for (i, s) in enumerate(self._gen_suffixes(), 1)))
        modules = []
        for name in os.listdir(imp_dir):
            (mod, suffix) = os.path.splitext(name)
            if (mod != '__init__'):
                init = os.path.join(name, '__init__.py')
                if os.path.exists(os.path.join(imp_dir, init)):
                    modules.append((0, name, (init, '__init__', False)))
                elif (suffix in suffixes):
                    modules.append((suffixes[suffix], mod, (name, None, False)))
        modules.sort(key=(lambda mod: mod[0]))
        for (_, mod, importable) in modules:
            if (mod not in importables):
                importables[mod] = importable
    return importables
