Metadata#

metadata module#

class mmodel.metadata.MetaDataFormatter(format_dict: dict, meta_order: list, text_wrapper: callable, shorten_list: list = <factory>)[source]#

Bases: object

Metadata Formatter.

mmodel.metadata.format_dictargs(key, value)[source]#

Format the metadata value that is a dictionary.

mmodel.metadata.format_func(key, value)[source]#

Format the metadata value that has a function.

The key name is not shown in the string output. The result is func(args1, args2, …).

mmodel.metadata.format_list(key, value)[source]#

Format the metadata value that is a list.

mmodel.metadata.format_modifierlist(key, value)[source]#

Format the metadata that is a list of modifiers.

The metadata of the modifier is extracted by the modifier_metadata function. The resulting list is formatted by the format_list function.

mmodel.metadata.format_obj_name(key, value)[source]#

Format the metadata value that is an object.

Only show the name of the object. This is used for graph and handler objects. The object needs to have __name__ or name attribute defined. If neither is defined, display the string representation.

mmodel.metadata.format_returns(key, value)[source]#

Format the metadata value that has a list of returns.

The formatter is for the returns metadata. If the “returns” value is empty, the output is None. If the returns only have one value, return the value; otherwise , return the values separated by commas in a tuple representation.

mmodel.metadata.format_shortdocstring(key, value)[source]#

Format function docstring.

Only the short docstring is parsed. The built-in and ufunc type docstring location is not consistent some module/function has the repr at the first line, and some don’t. Here we try to grab the first line that starts with an upper case and ends with a period.

mmodel.metadata.format_value(key, value)[source]#

Format the metadata without displaying the key.

mmodel.metadata.modifier_metadata(closure)[source]#

Extract metadata from closure, including the name and the arguments.

The order of extraction: 1. If the object has the “metadata” attribute defined. 2. If the closure takes no arguments, the name is the function name. 3. If the closure takes arguments, the “metadata” attribute is not defined.

Note:

inspect.getclosurevars(closure).nonlocals can only parse values
if the value is used in the closure.