mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
34 lines
966 B
Plaintext
34 lines
966 B
Plaintext
|
|
|
|
def dir_of_mod_or_default(module, default=None):
|
|
try:
|
|
mod = set(dir(__import__(module)))
|
|
return mod
|
|
except (ImportError, AttributeError):
|
|
return default
|
|
|
|
mod_names = [
|
|
name.decode() for name, ext in map(os.path.splitext, os.listdir(libdir))
|
|
if ext == b'.py' or os.path.isdir(f'{libdir}/{name}')]
|
|
mod_names += list(sys.builtin_module_names)
|
|
|
|
not_imported = {'not imported'}
|
|
rustpymods = {
|
|
mod: (dir_of_mod_or_default(mod, not_imported) if mod not in ("this", "antigravity") else None)
|
|
for mod in mod_names
|
|
}
|
|
|
|
for modname, cpymod in cpymods.items():
|
|
if modname in rustpymods:
|
|
rustpymod = rustpymods[modname]
|
|
if rustpymod:
|
|
if rustpymod == not_imported:
|
|
print(f"{modname} (existing but not importable)")
|
|
continue
|
|
for item in cpymod - rustpymod:
|
|
print(f"{modname}.{item}")
|
|
else:
|
|
print(f"{modname} (entire module)")
|
|
|
|
|