API Reference

class genpy.Generable[source]

A base class for AST nodes capable of generating code.

__str__()[source]

Return a single string (possibly containing newlines) representing this code construct.

abstract generate()[source]

Generate (i.e. yield) the lines making up this code construct.

class genpy.Suite(contents=None)[source]
__init__(contents=None)[source]
generate()[source]

Generate (i.e. yield) the lines making up this code construct.

append(data)[source]
extend(data)[source]
insert(i, data)[source]
extend_log_block(descr, data)[source]
class genpy.Collection(contents=None)[source]

Inherits from Suite, but does not lead to indentation.

Block nodes

class genpy.Class(name, bases, attributes)[source]

A class definition. Inherits from Generable.

__init__(name, bases, attributes)[source]
class genpy.If(condition, then_, else_=None)[source]

An `if/then/else block. Inherits from Generable.

__init__(condition, then_, else_=None)[source]
class genpy.Loop(body)[source]

An abstract base class for loops. class for loop blocks. Inherits from Generable.

__init__(body)[source]
abstract intro_line()[source]
outro_line()[source]
class genpy.CustomLoop(intro_line, body, outro_line=None)[source]

Inherits from Loop.

__init__(intro_line, body, outro_line=None)[source]
class genpy.While(condition, body)[source]

Inherits from Loop.

__init__(condition, body)[source]
class genpy.For(vars, iterable, body)[source]

Inherits from Loop.

__init__(vars, iterable, body)[source]
class genpy.Function(name, args, body, decorators=())[source]

Inherits from Generable.

__init__(name, args, body, decorators=())[source]
genpy.make_multiple_ifs(conditions_and_blocks, base=None)[source]

Single (logical) line Nodes

class genpy.Import(module)[source]

Inherits from Generable.

__init__(module)[source]
class genpy.ImportAs(module, as_)[source]

Inherits from Generable.

__init__(module, as_)[source]
class genpy.FromImport(module, names)[source]

Inherits from Generable.

__init__(module, names)[source]
class genpy.Statement(text)[source]

Inherits from Generable.

__init__(text)[source]
class genpy.Assign(lvalue, rvalue)[source]

Inherits from Generable.

__init__(lvalue, rvalue)[source]
class genpy.Line(text='')[source]

Inherits from Generable.

__init__(text='')[source]
class genpy.Return(expr)[source]

Inherits from Generable.

__init__(expr)[source]
class genpy.Raise(expr)[source]

Inherits from Generable.

__init__(expr)[source]
class genpy.Assert(expr)[source]

Inherits from Generable.

__init__(expr)[source]
class genpy.Yield(expr)[source]

Inherits from Generable.

__init__(expr)[source]
class genpy.Pass[source]

Inherits from Generable.

__init__()
class genpy.Comment(text)[source]

Inherits from Generable.

__init__(text)[source]