termite package¶
Subpackages¶
Submodules¶
termite.dependencies module¶
-
class
termite.dependencies.Edge(head, tail)¶ Bases:
termite.dependencies.Markable-
id()¶
-
-
class
termite.dependencies.Graph¶ -
class
GraphIterator(graph)¶
-
Graph.add_edge(edge)¶
-
Graph.add_vertex(vertex)¶
-
Graph.create_edge(tail_vertex, head_vertex)¶
-
Graph.find_circular_rings()¶
-
Graph.get_vertex(v_name)¶
-
Graph.is_circular()¶
-
class
-
class
termite.dependencies.PluginDependenciesManager¶ -
add_provider(dep_name, version, provider)¶ Should also mark if a require has been satisfied
-
all_dependencies_satisfied(dep_name)¶
-
dependency(name, providers=None)¶
-
get_dependency(name)¶
-
remove_dependency(dep_name)¶
-
remove_require(dep_name, require, min_version, max_version)¶
-
require(dep_name, require, min_version, max_version)¶ Dependency dep_name requires require in range min_version to max_version
-
reverese_dependency_order()¶
-
-
class
termite.dependencies.PluginDependency(name)¶ Bases:
termite.dependencies.Vertex-
add_provider(version, provider)¶
-
dependencies_satisfied()¶
-
get_providers(require)¶
-
-
class
termite.dependencies.Require(head, tail, min_version=None, max_version=None)¶ Bases:
termite.dependencies.Edge-
id()¶
-
is_satisfied()¶
-
is_satisfied_with(version)¶
-
mark_satisfied()¶
-
-
class
termite.dependencies.ServiceContext¶ -
locate_service(name, on_available, on_removed)¶
-
locate_services(services, on_all_available, on_removed, on_all_removed)¶
-
remove_service(name)¶
-
service(name, dependencies, factory)¶
-
termite.loader module¶
termite.main module¶
Program entry point
-
termite.main.entry_point()¶ Zero-argument entry point for use with setuptools/distribute.
-
termite.main.main(argv)¶ Program entry point.
Parameters: argv ( list) – command-line arguments
termite.platform module¶
termite.platformctl module¶
termite.resources module¶
Resources loading and management.
-
class
termite.resources.BaseResourceLoader(protocol_handlers=None)¶ Base class for ResourceLoader implementors.
A ResourceLoader is an object used to load some kind of resource. The resource may be loaded from the system, from a file, fetched from a store or a caching mechanism, or by other means. The resource may be loaded as a string, stream of bytes, a file or any other Python object (or may in fact be a Python object itself).
The ResourceLoader protocol defines only one method:
The
`load`method delegates the loading of the actual resource to a ProtocolHandler. The resource is loaded by its identifier. Optionally, an additional arguments may be passed to the`load`call which could provide hints for the resource loading process.This base class delegates the actual loading of the resource to pre-defined ProtocolHandlers. One handler is registered per protocol. When the actual protocol path is resolved from the resource id a ProtocolHandler for the requested protocol is located. If such handler is registered, the resolved resource path along with any additional arguments are passed to the handler to load the actual resource. This class provides means to register protocol handlers and resolution of resource id to a resource path and protocol.
-
add_handler(protocol, handler)¶ Registers a ProtocolHandler for the given protocol with this resource loader.
protocol is the protocol string (such as “http”, “file”, “zip”).
handler is the ProtocolHandler instance to be used when loading resources using the specified protocol.
-
get_handler(protocol)¶ Looks up a ProtocolHandler instance for the specified protocol.
If no such handler has been register, an Exception is raised.
Returns the found protocol handler.
-
get_path(str_specs)¶ Resolves the protocol and the resource path from the resource id spec string.
str_spec is the resource id string.
The method returns a tupple (protocol, path) where the protocol may be None.
-
load(str_specs, *args, **kwargs)¶ Loads the resource identified by a resource id.
The loading of the resources id done in two steps: first, the resource id is resolved to a specific protocol and a resoruce path. Then a protocol handler is looked up for the specific protocol and the loading of the resource is delegated to it by passing the resolved resource path along with any additional arguments.
str_specs is the string representation of the resource id. The specification for the resource id is defined like this:
[[<protocol>:]...]<resource_id>- where:
- protocol is the protocol that determines the means of accessing
the resource (e.g. “file”, “plugin”, “class”, etc). * resource_id is the actual resource ID. In the context of the access mechanism (protocol handler), this may be: the file path, the name of the plugin, the full class name, etc.
- Some examples of resource ids:
- plugin:core-event-loop
- file:conf/platform.ini
- class:nanopp.platform.Platform
- singleton-object
- bca87585-18bd-440f-87a9-7cc44e56a639
- or, some complex ones:
- plugin:tar.gz:my-plugin-2.3
- plugin:zip:ui-plugin.zip
- file:zip:archive.zip/someFile.txt
The method returns the loaded resource by the protocol handler. It throws an Exception if:
- there is no registered handler for the actual prtoocol (the protocol
is not supported) * any error occurs while actually loading the resource
-
termite.tools module¶
-
class
termite.tools.Proxy(target)¶ Proxy wrapper that adds facilities for intercepting inerations.
Wraps the original (target) object and exposes its methods and properties as its own. This is achieved by overriding the __getattribute__ native method. When a property is requested (reading/setting a value to a property, calling a method) on the proxy object, the wrapped object is inspected and a convinient wrapper is returned back to the requestor. For the requesting party, the proxy object follows the same interface as the original object type. Some special methods that belong specifically to the Proxy type are available and will not be proxied (see the list of NATIVE_METHODS).
There are three extension points defined by the proxy that add facilities for interception of the interaction:
- on_method_call - called every time a method is called and it exists in the
original object
on_property - called when a property is requested (to be read or written to)
on_missing - called when the actual method does not exist
-
NATIVE_METHODS= ['target', '__method_call_wrapper__', 'on_method_call', 'on_property', 'on_missing', '__init__']¶
-
on_method_call(name, actual_method, *args, **kwargs)¶ Called every time a method is called on the proxy and exists in the target.
This is intended to be overriden in a subclass when extending. This method does not have to be implemented by any extending class. By default it will call the actual method from the proxied instance.
name is the name of the called method.
actual_method is an actual reference to the method from the underlying target method.
args is a tupple of the arguments passed to the method call.
kwargs is a dictionary of the arguments passed to the method call.
By default returns the actual result of the method call.
-
on_missing(name)¶ Called when a request is being made to a non-existing property or method in the proxied object.
Since it cannot be determined whether the request is for a property (to get or set a value) or a method call, only the name of the requested attribute is passed down to the call.
name is the name of the property or method being requested.
Returns a reference to a no-operation property. This is a callable instance that when called does not perform any operation (NOOP), but is not None.
-
on_property(name, prop_value)¶ Called every time a property is requested and exists in the target.
This method is intended to be implemented in an extending class. By default it will return the actual reference to the property of the proxied instance.
name is the name of the requested property.
prop_value is the actual value (reference) of the property in the proxied object
By default returns the actual value of the property in the proxied object.
Module contents¶
It does cool things