module translation.translation_class
¶
Short summary¶
module pysqllike.translation.translation_class
One class which visits a syntax tree.
Classes¶
class |
truncated documentation |
---|---|
Interface for a class which translates a code written in pseudo-SQL syntax into another language. |
Methods¶
method |
truncated documentation |
---|---|
Constructor. |
|
Returns a string representing a tree. |
|
Returns the code of the initial Python function into another language. |
|
Parses the function code and add it the class, it complements the constructor. |
|
Starts the interpretation of node which begins a function. |
|
Starts the interpretation of a node which sets a return. |
|
Builds an instruction of a function based on its name and its children. |
|
Raises an exception when interpreting the code. |
|
Produces an expression based on a a node and its children. |
|
Interprets a select statement. |
|
Indicates all nodes containing information about returned results. |
|
Build the signature of a function based on its name and its children. |
|
Returns a string representing a tree. |
|
Interprets a select statement. |
Documentation¶
One class which visits a syntax tree.
- class pysqllike.translation.translation_class.TranslateClass(code_func)¶
Bases:
object
Interface for a class which translates a code written in pseudo-SQL syntax into another language.
Constructor.
- Parameters:
code_func – code (str) or function(func)
- Code()¶
Returns the code of the initial Python function into another language.
- Returns:
str
- Intruction(rows)¶
Builds an instruction of a function based on its name and its children.
- Parameters:
rows – node where type == Assign
- Returns:
list of strings (code)
- RaiseCodeException(message, field='processed', code_rows=None)¶
Raises an exception when interpreting the code.
- Parameters:
field – field to add to the message exception
code_rows – list of rows to display
- Raises:
CodeException
- ResolveExpression(node, prefixAtt)¶
Produces an expression based on a a node and its children.
- Parameters:
node – node
prefixAtt – prefix to add before an attribute (usually _)
- Returns:
a string, the used fields, the called functions
- Select(name, table, rows)¶
Interprets a select statement.
- Parameters:
name – name of the table which receives the results
table – name of the table it applies to
rows – rows to consider
- Returns:
list of strings (code)
- Signature(name, rows)¶
Build the signature of a function based on its name and its children.
- Parameters:
name – name
rows – node where type == arguments
- Returns:
list of strings (code)
- Where(name, table, rows)¶
Interprets a select statement.
- Parameters:
name – name of the table which receives the results
table – name of the table it applies to
rows – rows to consider
- Returns:
list of strings (code)
- __init__(code_func)¶
Constructor.
- Parameters:
code_func – code (str) or function(func)
- __str__()¶
Returns a string representing a tree.
- _symbols = {'Gt': '>', 'Lt': '<', 'Mult': '*'}¶
- init(code)¶
Parses the function code and add it the class, it complements the constructor.
- Parameters:
code – function code
- interpretFunction(obj)¶
Starts the interpretation of node which begins a function.
- Parameters:
obj – obj to begin with (a function)
- Returns:
list of strings
- interpretReturn(obj)¶
Starts the interpretation of a node which sets a return.
- Parameters:
obj – obj to begin with (a function)
- Returns:
list of strings
- setReturn(nodes)¶
Indicates all nodes containing information about returned results.
- Parameters:
node – list of nodes
- Returns:
list of string
- to_str(fields=None)¶
Returns a string representing a tree.
- Parameters:
fields – additional fields to add at the end of each row
- Returns:
string