py1.curly

Implements the un-escaping of the {{ }} indents.

Functions

unescape(code_str) Substitutes ‘{{‘ by indents and ‘}}’ by dedents.

Classes

Token Represents a single Token.
TokenAndPos Represents a single Token and its position.

Exceptions

CannotTokenize(message, position) Raised when the tokenize module failed.
Error Base class for errors from this module.
Mismatch(message, token_and_pos) There is not the same number of ‘{{‘ and ‘}}’.
exception CannotTokenize(message, position)[source]

Raised when the tokenize module failed.

exception Error[source]

Base class for errors from this module.

exception Mismatch(message, token_and_pos)[source]

There is not the same number of ‘{{‘ and ‘}}’.

class Token[source]

Represents a single Token.

num

The token type as per the tokenize module.

val

The token value as per the tokenize module.

class TokenAndPos[source]

Represents a single Token and its position.

token

A Token object.

start

a (row, col) tuple specifying where the token begins.

end

a (row, col) tuple specifying where the token ends.

unescape(code_str)[source]

Substitutes ‘{{‘ by indents and ‘}}’ by dedents.

Parameters:code_str – The 1-line Python snippet.
Returns:Standard valid Python as a string.
Raises:Error – The conversion failed.