module translation.translation_class

Inheritance diagram of pysqllike.translation.translation_class

Short summary

module pysqllike.translation.translation_class

One class which visits a syntax tree.

source on GitHub

Classes

class

truncated documentation

TranslateClass

Interface for a class which translates a code written in pseudo-SQL syntax into another language.

Methods

method

truncated documentation

__init__

Constructor.

__str__

Returns a string representing a tree.

Code

Returns the code of the initial Python function into another language.

init

Parses the function code and add it the class, it complements the constructor.

interpretFunction

Starts the interpretation of node which begins a function.

interpretReturn

Starts the interpretation of a node which sets a return.

Intruction

Builds an instruction of a function based on its name and its children.

RaiseCodeException

Raises an exception when interpreting the code.

ResolveExpression

Produces an expression based on a a node and its children.

Select

Interprets a select statement.

setReturn

Indicates all nodes containing information about returned results.

Signature

Build the signature of a function based on its name and its children.

to_str

Returns a string representing a tree.

Where

Interprets a select statement.

Documentation

One class which visits a syntax tree.

source on GitHub

class pysqllike.translation.translation_class.TranslateClass(code_func)[source]

Bases: object

Interface for a class which translates a code written in pseudo-SQL syntax into another language.

source on GitHub

Constructor.

Parameters

code_func – code (str) or function(func)

source on GitHub

Code()[source]

Returns the code of the initial Python function into another language.

Returns

str

source on GitHub

Intruction(rows)[source]

Builds an instruction of a function based on its name and its children.

Parameters

rows – node where type == Assign

Returns

list of strings (code)

source on GitHub

RaiseCodeException(message, field='processed', code_rows=None)[source]

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

source on GitHub

ResolveExpression(node, prefixAtt)[source]

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

source on GitHub

Select(name, table, rows)[source]

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)

source on GitHub

Signature(name, rows)[source]

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)

source on GitHub

Where(name, table, rows)[source]

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)

source on GitHub

__init__(code_func)[source]

Constructor.

Parameters

code_func – code (str) or function(func)

source on GitHub

__str__()[source]

Returns a string representing a tree.

source on GitHub

_symbols = {'Gt': '>', 'Lt': '<', 'Mult': '*'}
init(code)[source]

Parses the function code and add it the class, it complements the constructor.

Parameters

code – function code

source on GitHub

interpretFunction(obj)[source]

Starts the interpretation of node which begins a function.

Parameters

obj – obj to begin with (a function)

Returns

list of strings

source on GitHub

interpretReturn(obj)[source]

Starts the interpretation of a node which sets a return.

Parameters

obj – obj to begin with (a function)

Returns

list of strings

source on GitHub

setReturn(nodes)[source]

Indicates all nodes containing information about returned results.

Parameters

node – list of nodes

Returns

list of string

source on GitHub

to_str(fields=None)[source]

Returns a string representing a tree.

Parameters

fields – additional fields to add at the end of each row

Returns

string

source on GitHub