Commit 5b937092 authored by Andreas Dedner's avatar Andreas Dedner

add a `dune.utility.components` function that gives information about

available modules
parent e4a6aea8
Pipeline #16927 passed with stage
in 16 minutes and 5 seconds
......@@ -12,6 +12,7 @@ add_python_targets(dune
create
plotting
deprecate
utility
)
dune_add_pybind11_module(NAME _typeregistry)
......
......@@ -67,16 +67,32 @@ def get(category=None,entry=None):
if entry_ is None:
if category is not None:
print("category '",category,"' not valid,",end="")
print("available categories are:",
','.join(k for k in _create_map))
print("available categories are:\n",
','.join(k for k in sorted(_create_map)))
return
if entry is None:
print("available entries for this category are:")
entries = []
colLength = [0,0,0]
for k,e in entry_.items():
n = e[0].__module__.split(".")
if n[-1][0]=="_":
del n[-1]
print(k,"\t\t\t function'"+e[0].__name__+"' from '"+'.'.join(m for m in n)+"'")
entries += [ [k,e[0].__name__, '.'.join(m for m in n)] ]
colLength[0] = max(colLength[0],len(entries[-1][0]))
colLength[1] = max(colLength[1],len(entries[-1][1]))
colLength[2] = max(colLength[2],len(entries[-1][2]))
# print(k,"\t function'"+e[0].__name__+"' from '"+'.'.join(m for m in n)+"'")
entries.sort()
print("entry".ljust(colLength[0]),
"function".ljust(colLength[1]),
"module".ljust(colLength[2]))
print("-"*sum(colLength))
for e in entries:
print(e[0].ljust(colLength[0]),
e[1].ljust(colLength[1]),
e[2].ljust(colLength[2]))
print("-"*sum(colLength))
else:
entry__ = entry_.get(entry,None)
if entry__ is None:
......
from dune.create import get as components
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment