bgdev.tools.pypredef¶
Generate pypredefs using Maya’s help query to read command flags.
- created
18/05/2018
- author
Benoit GIELLY <benoit.gielly@gmail.com>
-
cleanup_flags
(docstring)[source]¶ Cleanup the docstring from the mel output to a nicer result.
- Parameters
docstring (str) – The docstring extracted from the help command query.
Example
Reformat this docstring:
Flags: -n -name String -p -parent String -s -shared -ss -skipSelect
So it looks like this:
Flags: name (n): String parent (p): String shared (s): None skipSelect (ss): None
Also returns a list of all the flags so they can be added to the method definition (eg. “flag=None”) so IDE can autocomplete them.
- Parameters
docstring (str) – The docstring containing the flags to cleanup.
- Returns
The cleaned-up docstring with nicer flags, and the list of flags
- Return type
tuple
-
generate_pypredef
(module, outdir=None, doclink=True)[source]¶ Generate pypredefs using Maya’s help query to read command flags.
- Parameters
module (mod) – Module from which you want to generate the pypredef.
outdir (str) – Directory in which you want to export the text file.
doclink (bool) – Adds a link to the online documentation.
Note
There are a few maya commands (e.g. “nexCtx”) that are almost 1 MILLION line length… so there’s a test to skip the command if the docstring is longer than 10k lines.
Example
from maya import cmds generate_pypredef(cmds, outdir="~/Desktop")
-
get_maya_urls
()[source]¶ Generate a table for each commands from the online documentation.
- Returns
Generates a {command:url} dictionnary.
- Return type
dict
-
indent
(text, amount=4)[source]¶ Indent each lines of the given string.
- Parameters
text (str) – Text to indent
amount (int) – Number or character padding
- Returns
Indented text.
- Return type
str
-
iskeyword
()¶ x.__contains__(y) <==> y in x.