Client API

taco

The taco module imports the Taco class from the taco.client module, allowing it to be imported as follows:

from taco import Taco

taco.client

class taco.client.Taco(lang=None, script=None, disable_context=False)

Taco client class.

Example:

from taco import Taco

taco = Taco(lang='python')

taco.import_module('time', 'sleep')
taco.call_function('sleep', 5)
call_class_method(class_, name, *args, **kwargs)

Invoke a class method call in the connected server.

The context (void / scalar / list) can be specified as a keyword argument “context” unless the “disable_context” attribute has been set.

call_function(name, *args, **kwargs)

Invoke a function call in the connected server.

The context (void / scalar / list) can be specified as a keyword argument “context” unless the “disable_context” attribute has been set.

construct_object(class_, *args, **kwargs)

Invoke an object constructor.

If successful, this should return a TacoObject instance which references the new object. The given arguments and keyword arguments are passed to the object constructor.

get_value(name)

Request the value of the given variable.

import_module(name, *args, **kwargs)

Instruct the server to load the specified module.

The interpretation of the arguments depends on the language of the Taco server implementation.

set_value(name, value)

Set the value of the given variable.

function(name)

Convience method giving a function which calls call_function.

This example is equivalent to that given for this class:

sleep = taco.function('sleep')
sleep(5)
constructor(class_)

Convience method giving a function which calls construct_object.

For example constructing multiple datetime objects:

taco.import_module('datetime', 'datetime')
afd = taco.construct_object('datetime', 2000, 4, 1)

Could be done more easily:

datetime = taco.constructor('datetime')
afd = datetime(2000, 4, 1)

taco.object

class taco.object.TacoObject(client, number)

Taco object class.

This class is used to represent objects by Taco actions. Instances of this class will returned by methods of Taco objects and should not normally be constructed explicitly.

The objects reside on the server side and are referred to by instances of this class by their object number. When these instances are destroyed the destroy_object action is sent automatically.

call_method(*args, **kwargs)

Invoke the given method on the object.

The first argument is the method name.

The context (void / scalar / list) can be specified as a keyword argument “context” unless the “disable_context” attribute of the client has been set.

get_attribute(*args, **kwargs)

Retrieve the value of the given attribute.

set_attribute(*args, **kwargs)

Set the value of the given attribute.

method(name)

Convenience method giving a function which calls a method.

Returns a function which can be used to invoke a method on the server object. For example:

strftime = afd.method('strftime')
print(strftime('%Y-%m-%d'))

taco.error

exception taco.error.TacoError

Base class for specific Taco client exceptions.

Note that the client can also raise general exceptions, such as ValueError, if its methods are called with invalid arguments.

exception taco.error.TacoReceivedError

An exception raised by the Taco client.

Raised if the client receives an exception action. The exception message will contain any message text received in the exception action.

exception taco.error.TacoUnknownActionError

An exception raised by the Taco client.

Raised if the client receives an action of an unknown type.