Пример #1
0
"""
This module extends the odML base class by adding tree-functionality for
gtk.GenericTreeModels using MixIns

to use it just import this module::

    >>> import odmlui.treemodel.mixin

Alternatively you can import the modified Value/Property/Section/Document
classes manually::

    >>> import odml.tools.nodes as odml
    >>> s = odml.Section("animal_keeping section")

Or get the implementation once it is registered::

    >>> import odml
    >>> import odml.tools.nodes
    >>> odml.getImplementation('nodes').Section("animal_keeping section")

"""
# Please note: tree-functionality is already based on event-functionality.
# Therefore mixin in odml.tools.events will be troublesome / not work.

import odml

from . import nodes

odml.setMinimumImplementation('nodes')
Пример #2
0
# -*- coding: utf-8
"""
generic odml validation framework
"""
import format
import mapping
import tools.event
import odml

# event capabilities are needed for mappings
odml.setMinimumImplementation("event")


class ValidationError(object):
    """
    Represents an error found in the validation process
    
    The error is bound to an odml-object (*obj*) or a list of those
    and contains a message and a type which may be one of:
    'error', 'warning', 'info'
    """

    def __init__(self, obj, msg, type="error"):
        self.obj = obj
        self.msg = msg
        self.type = type

    @property
    def is_warning(self):
        return self.type == "warning"
Пример #3
0
"""
This module extends the odML base class by adding tree-functionality for
gtk.GenericTreeModels using MixIns

to use it just import this module::

    >>> import odml.gui.treemodel.mixin

Alternatively you can import the modified Value/Property/Section/Document
classes manually::

    >>> import odml.tools.nodes as odml
    >>> s = odml.Section("sample section")

Or get the implementation once it is registered::

    >>> import odml
    >>> import odml.tools.nodes
    >>> odml.getImplementation('nodes').Section("sample section")

"""
#Please note: tree-functionality is already based on event-functionality.
#Therefore mixin in odml.tools.events will be troublesome / not work.

import odml
import odml.tools.nodes
odml.setMinimumImplementation('nodes')

Пример #4
0
import odml
import event
import weakmeth, weakref
import nodes

# events are required for proxy objects 
odml.setMinimumImplementation('event')

class Proxy(object):
    """common interface"""
    pass

# here we hook the base-class-comparism functionality to
# prefer comparism provided by the proxy obj
_odml_base___eq__ = odml.base.baseobject.__eq__
def _proxy___eq__(self, obj):
    if isinstance(obj, Proxy) and not isinstance(self, Proxy):
        return obj == self
    return _odml_base___eq__(self, obj)

odml.base.baseobject.__eq__ = _proxy___eq__

class BaseProxy(Proxy):
    """
    A nonfunctional proxy, having only the delegate
    self._proxy_obj

    Comparism is hooked, so the following always holds

        >>> BaseProxy(o) == o
        True
Пример #5
0
#-*- coding: utf-8
"""
generic odml validation framework
"""
import format
import mapping
import tools.event
import odml

# event capabilities are needed for mappings
odml.setMinimumImplementation('event')

class ValidationError(object):
    """
    Represents an error found in the validation process
    
    The error is bound to an odml-object (*obj*) or a list of those
    and contains a message and a type which may be one of:
    'error', 'warning', 'info'
    """
    def __init__(self, obj, msg, type='error'):
        self.obj = obj
        self.msg = msg
        self.type = type

    @property
    def is_warning(self):
        return self.type == 'warning'

    @property
    def is_error(self):