polynomials_on_simplices.generic_tools.code_generation_utils module

Utilities for generating code.

class CodeWriter[source]

Bases: object

Class used to generate formatted text, i.e. text with control of indentation and scope. Useful for generating code.

al(string)[source]

Append code to the current line.

bl(string)[source]

Begin a line of code.

count_num_lines()[source]

Count number of lines in the code.

Returns:Number of lines in the code.
dec_indent()[source]

Decrease indent depth.

el(string)[source]

Append code to the current line and end line.

empty()[source]

Check if anything has been written.

get_scope()[source]

Get current scope.

inc_indent()[source]

Increase indent depth.

pop_first_line()[source]

Pop and return first line from code.

pop_scope()[source]

Pop scope.

print_trace(message='')[source]

Insert debug information into code. Useful for tracing the origin of the code.

push_scope(scope_name)[source]

Push scope.

reset()[source]

Reset code writer.

verbatim(string)[source]

Write code verbatim.

wc(string)[source]

Write several lines of code.

wl(string)[source]

Write a line of code.

ws()[source]

Output current scope.