refs #0 The root commit.
This commit is contained in:
38
back/help.py
Executable file
38
back/help.py
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/local/bin/python
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
from click import argument, command
|
||||
|
||||
|
||||
@command()
|
||||
@argument("path")
|
||||
def pyhelp(path: str):
|
||||
"""
|
||||
Print the object documentation from docstring.
|
||||
|
||||
:param path: The full path to the module, function or class.
|
||||
"""
|
||||
|
||||
module_path = path.rsplit(".", 1)[0]
|
||||
object_name = path.split(".")[-1]
|
||||
|
||||
try:
|
||||
module = import_module(module_path)
|
||||
except ModuleNotFoundError:
|
||||
module = None
|
||||
|
||||
if module:
|
||||
if module_path == object_name:
|
||||
_object = module
|
||||
else:
|
||||
_object = getattr(module, object_name, None)
|
||||
else:
|
||||
_object = getattr(__builtins__, object_name, None)
|
||||
|
||||
if _object:
|
||||
help(_object)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pyhelp()
|
||||
Reference in New Issue
Block a user