SCRIPT ################################## Used to generate a script that uses the Polygraphy API.
More...
|
def | __init__ (self, summary=None) |
|
def | add_import (self, imports, frm=None) |
|
def | add_loader (self, loader_str, loader_id, suffix=None) |
|
def | get_runners (self) |
|
def | add_runner (self, runner_str) |
|
def | append_preimport (self, line) |
|
def | append_prefix (self, line) |
|
def | append_suffix (self, line) |
|
def | __str__ (self) |
|
SCRIPT ################################## Used to generate a script that uses the Polygraphy API.
◆ __init__()
def polygraphy.tools.util.script.Script.__init__ |
( |
|
self, |
|
|
|
summary = None |
|
) |
| |
Represents a Python script that uses the Polygraphy API.
summary (str):
A summary of what the script does, which will be included in the script as a comment.
◆ format_str()
def polygraphy.tools.util.script.Script.format_str |
( |
|
base_str, |
|
|
* |
args, |
|
|
** |
kwargs |
|
) |
| |
|
static |
Like str.format(), but includes string arguments with quotes, unless
they are marked Inline.
Examples:
format_str("{:} is my name", "polygraphy")
-> "'polygraphy' is my name"
format_str("{:} is my name", Inline("polygraphy"))
-> "polygraphy is my name"
◆ invoke()
def polygraphy.tools.util.script.Script.invoke |
( |
|
type_str, |
|
|
* |
args, |
|
|
** |
kwargs |
|
) |
| |
|
static |
Creates a string representation that will invoke the specified object,
with the specified arguments.
Args:
type_str (str): A string representing the object that should be invoked.
args, kwargs:
Arguments to pass along to the object. If a keyword argument
is set to None, it will be omitted.
Returns:
str: A string representation that invokes the object specified.
Examples:
Script.invoke("MyClass", 0, 1, last=3)
-> "MyClass(0, 1, last=3)"
Script.invoke("my_func", 0, 1, last=None)
-> "my_func(0, 1)"
◆ invoke_if_nondefault()
def polygraphy.tools.util.script.Script.invoke_if_nondefault |
( |
|
type_str, |
|
|
* |
args, |
|
|
** |
kwargs |
|
) |
| |
|
static |
Similar to `invoke`, but will return None if all arguments are None.
Examples:
Script.invoke("MyClass", 0, 1, last=3)
-> "MyClass(0, 1, last=3)"
Script.invoke("my_func", None, None, last=None)
-> None
◆ add_import()
def polygraphy.tools.util.script.Script.add_import |
( |
|
self, |
|
|
|
imports, |
|
|
|
frm = None |
|
) |
| |
Adds imports to this script
Args:
imports (List[str]): List of components to import
frm (str): Module frm which to import
◆ add_loader()
def polygraphy.tools.util.script.Script.add_loader |
( |
|
self, |
|
|
|
loader_str, |
|
|
|
loader_id, |
|
|
|
suffix = None |
|
) |
| |
Adds a loader to the script.
If the loader is a duplicate, returns the existing loader instead.
Args:
loader_str (str): A string constructing the loader.
loader_id (str): A short human-friendly identifier for the loader
Returns:
str: The name of the loader added.
◆ get_runners()
def polygraphy.tools.util.script.Script.get_runners |
( |
|
self | ) |
|
◆ add_runner()
def polygraphy.tools.util.script.Script.add_runner |
( |
|
self, |
|
|
|
runner_str |
|
) |
| |
Adds a runner to the script.
Args:
runner_str (str): A string constructing the runner
◆ append_preimport()
def polygraphy.tools.util.script.Script.append_preimport |
( |
|
self, |
|
|
|
line |
|
) |
| |
Append a line to the pre-import prefix of the script
Args:
line (str): The line to append.
◆ append_prefix()
def polygraphy.tools.util.script.Script.append_prefix |
( |
|
self, |
|
|
|
line |
|
) |
| |
Append a line to the prefix of the script
Args:
line (str): The line to append.
◆ append_suffix()
def polygraphy.tools.util.script.Script.append_suffix |
( |
|
self, |
|
|
|
line |
|
) |
| |
Append a line to the suffix of the script
Args:
line (str): The line to append.
◆ __str__()
def polygraphy.tools.util.script.Script.__str__ |
( |
|
self | ) |
|
◆ imports
polygraphy.tools.util.script.Script.imports |
◆ from_imports
polygraphy.tools.util.script.Script.from_imports |
◆ loaders
polygraphy.tools.util.script.Script.loaders |
◆ loader_count
polygraphy.tools.util.script.Script.loader_count |
◆ runners
polygraphy.tools.util.script.Script.runners |
◆ preimport
polygraphy.tools.util.script.Script.preimport |
◆ prefix
polygraphy.tools.util.script.Script.prefix |
◆ suffix
polygraphy.tools.util.script.Script.suffix |
◆ summary
polygraphy.tools.util.script.Script.summary |
The documentation for this class was generated from the following file: