IndentedOutput
- class omni.graph.tools.IndentedOutput(output: IO)
Bases:
object
Helper class that provides output capabilities to messages with preserved indentation levels
- Properties:
output: File type that receives the output indent_level: Number of indentation levels for the current output indent_string: String representing the current indentation level
Methods
__init__
(output)Initialize the indentation level and prepare for output
close
()Close the output stream
exdent
([message])Decrease the indentation level for emitted code
indent
([message])Increase the indentation level for emitted code
prepend
(message)Write the message line at the beginning of the output.
write
([message])Output a single message line to the file.
write_as_is
(message)Output a string to the output file without indentation or added newline Passing in a list will write each list member on its own line.
- __init__(output: IO)
Initialize the indentation level and prepare for output
- Parameters
output – IO object to which this object will be sending its output Both io.TextIOWrapper (output from “open()”) and io.StringIO can be used
- close()
Close the output stream
- exdent(message: Optional[str] = None)
Decrease the indentation level for emitted code
If a message is specified then emit that message immediately after exdenting, allowing you to easily close sections like: out.exdent(“}”)
- indent(message: Optional[str] = None) bool
Increase the indentation level for emitted code
If a message is specified then emit that message immediately before indenting, allowing you to easily open sections like: out.indent(“{“)
- Returns True so that indented sections can be indented in the code:
- if output.indent(“begin {“):
output.exdent(“})
- prepend(message: str)
Write the message line at the beginning of the output.
This rewrites the entire output so it is best to minimize its use, and stick with string implementations. The message is written as-is with no newlines or indenting
- write(message: Union[List, str] = '')
Output a single message line to the file. This assumes indentation will be used and a newline will be appended. Passing in a list will write each list member on its own line.
- Parameters
message – Line of text being emitted
- write_as_is(message: Union[List, str])
Output a string to the output file without indentation or added newline Passing in a list will write each list member on its own line.
- Parameters
message – Line of text being emitted