Made the world slightly worse

This commit is contained in:
GodSaveTheDoge 2022-02-09 22:50:18 +01:00
parent 3d31a2d7e5
commit 93a127beed
3 changed files with 31 additions and 1 deletions

View File

@ -1,2 +1,3 @@
# Phpython
Are you tired of writing so many import statements?
Fear not, with Phpython you can just `from star import *`

28
star/__init__.py Normal file
View File

@ -0,0 +1,28 @@
# How this works:
#
# - Make a list of everyhing importable and expose it with __all__
# - Python fetches __all__ and tries to import everything
# - Via __getattr__ when the stuff starts getting imported by python, import
# the required module and return it
# - Profit ???
import sys
import os
mods = [
[
f.split(".", 1)[0]
for f in os.listdir(spath)
if f.endswith(".py")
or (
os.path.isdir(f)
and os.path.exists(os.path.join(f, "__init__.p__init__.py"))
)
]
for spath in sys.path
if os.path.exists(spath)
]
__all__ = [f for m in mods for f in m]
__path__ = []
def __getattr__(name):
return __import__(name)

1
star/__main__.py Normal file
View File

@ -0,0 +1 @@
breakpoint()