Ejemplo n.º 1
0
class GraphTemplate(Template):
    # TODO: Is there a way to specify a default/static value for form?
    form = StringField('@form', choices=['graph'])
    graph = NodeField('graph', Graph)
Ejemplo n.º 2
0
class IdNode(XmlObject):
    id = StringField('@id')
Ejemplo n.º 3
0
class XpathVariable(XmlObject):
    ROOT_NAME = 'variable'
    name = StringField('@name')

    locale_id = StringField('locale/@id')
Ejemplo n.º 4
0
class LocaleId(XmlObject):
    ROOT_NAME = 'locale'
    locale_id = StringField('@id')
Ejemplo n.º 5
0
class CommandMixin(XmlObject):
    ROOT_NAME = 'command'
    relevant = StringField('@relevant')
Ejemplo n.º 6
0
class ConfigurationItem(Text):
    ROOT_NAME = "text"
    id = StringField("@id")
Ejemplo n.º 7
0
class MediaResource(AbstractResource):
    ROOT_NAME = 'media'
    path = StringField('@path')
Ejemplo n.º 8
0
class AuthKeys(XmlObject):
    ROOT_NAME = 'auth_keys'
    domain = StringField('@domain', required=True)
    issued = CustomDateTimeField('@issued', required=True)

    key_records = NodeListField('key_record', KeyRecord, required=True)
Ejemplo n.º 9
0
class Value(LedgerXML):
    ROOT_NAME = 'value'
    section_id = StringField('@section-id', required=False)
    quantity = IntegerField('@quantity', required=True)
Ejemplo n.º 10
0
class CalculatedPropertyXpathVariable(XmlObject):
    ROOT_NAME = 'variable'
    name = StringField('@name')
    locale_id = StringField('locale/@id')
Ejemplo n.º 11
0
class Detail(OrderedXmlObject, IdNode):
    """
    <detail id="">
        <title><text/></title>
        <lookup action="" image="" name="">
            <extra key="" value = "" />
            <response key ="" />
        </lookup>
        <variables>
            <__ function=""/>
        </variables>
        <field sort="">
            <header form="" width=""><text/></header>
            <template form=""  width=""><text/></template>
        </field>
    </detail>
    """

    ROOT_NAME = 'detail'
    ORDER = ('title', 'lookup', 'details', 'fields')

    nodeset = StringField('@nodeset')
    print_template = StringField('@print-template')

    title = NodeField('title/text', Text)
    lookup = NodeField('lookup', Lookup)
    fields = NodeListField('field', Field)
    actions = NodeListField('action', Action)
    details = NodeListField('detail', "self")
    _variables = NodeField('variables', DetailVariableList)
    relevant = StringField('@relevant')

    def _init_variables(self):
        if self._variables is None:
            self._variables = DetailVariableList()

    def _get_variables_node(self):
        self._init_variables()
        return self._variables.variables

    def _set_variables_node(self, value):
        self._init_variables()
        self._variables.variables = value

    variables = property(_get_variables_node, _set_variables_node)

    def has_variables(self):
        # can't check len(self.variables) directly since NodeList uses an
        # xpath to find its children which doesn't work here since
        # each node has a custom name
        return self._variables is not None and len(
            self.variables.node.getchildren()) > 0

    def get_variables(self):
        """
        :returns: List of DetailVariable objects
        """
        return [
            self.variables.mapper.to_python(node)
            for node in self.variables.node.getchildren()
        ]

    def get_all_xpaths(self):
        result = set()

        if self.nodeset:
            result.add(self.nodeset)
        if self.has_variables():
            for variable in self.get_variables():
                result.add(variable.function)

        if self.actions:
            for action in self.actions:
                for frame in action.stack.frames:
                    result.add(frame.if_clause)
                    for datum in getattr(frame, 'datums', []):
                        result.add(datum.value)

        def _get_graph_config_xpaths(configuration):
            result = set()
            for config in configuration.configs:
                result.add(config.xpath_function)
            return result

        for field in self.fields:
            if field.template.form == 'graph':
                s = etree.tostring(field.template.node)
                template = load_xmlobject_from_string(s,
                                                      xmlclass=GraphTemplate)
                result.update(
                    _get_graph_config_xpaths(template.graph.configuration))
                for series in template.graph.series:
                    result.add(series.nodeset)
                    result.update(
                        _get_graph_config_xpaths(series.configuration))
            else:
                result.add(field.header.text.xpath_function)
                result.add(field.template.text.xpath_function)
                if field.template.text.xpath:
                    for variable in field.template.text.xpath.variables:
                        if variable.xpath:
                            result.add(six.text_type(variable.xpath.function))

        for detail in self.details:
            result.update(detail.get_all_xpaths())
        result.discard(None)
        return result
Ejemplo n.º 12
0
class Itemset(XmlObject):
    ROOT_NAME = 'itemset'
    nodeset = StringField('@nodeset')
    value_ref = StringField('value/@ref')
    label_ref = StringField('label/@ref')
    sort_ref = StringField('sort/@ref')
Ejemplo n.º 13
0
class MediaResource(AbstractResource):
    ROOT_NAME = 'media'
    path = StringField('@path')
    lazy = SimpleBooleanField('resource/@lazy', true="true", false="false")
Ejemplo n.º 14
0
class Sort(AbstractTemplate):
    ROOT_NAME = 'sort'

    type = StringField('@type')
    order = StringField('@order')
    direction = StringField('@direction')
Ejemplo n.º 15
0
class Locale(XmlObject):
    ROOT_NAME = 'locale'
    id = StringField('@id')
    child_id = NodeField('id', Id)
    arguments = NodeListField('argument', LocaleArgument)
Ejemplo n.º 16
0
class MediaText(XmlObject):
    ROOT_NAME = 'text'
    form_name = StringField('@form',
                            choices=['image', 'audio'
                                     ])  # Nothing XForm-y about this 'form'
    locale = NodeField('locale', LocaleId)
Ejemplo n.º 17
0
class Detail(OrderedXmlObject, IdNode):
    """
    <detail id="">
        <title><text/></title>
        <lookup action="" image="" name="">
            <extra key="" value = "" />
            <response key ="" />
        </lookup>
        <variables>
            <__ function=""/>
        </variables>
        <field sort="">
            <header form="" width=""><text/></header>
            <template form=""  width=""><text/></template>
        </field>
    </detail>
    """

    ROOT_NAME = 'detail'
    ORDER = ('title', 'lookup', 'details', 'fields')

    nodeset = StringField('@nodeset')
    print_template = StringField('@print-template')

    title = NodeField('title/text', Text)
    lookup = NodeField('lookup', Lookup)
    fields = NodeListField('field', Field)
    actions = NodeListField('action', Action)
    details = NodeListField('detail', "self")
    _variables = NodeField('variables', DetailVariableList)

    def _init_variables(self):
        if self._variables is None:
            self._variables = DetailVariableList()

    def get_variables(self):
        self._init_variables()
        return self._variables.variables

    def set_variables(self, value):
        self._init_variables()
        self._variables.variables = value

    variables = property(get_variables, set_variables)

    def get_all_xpaths(self):
        result = set()

        if self.nodeset:
            result.add(self.nodeset)
        if self._variables:
            for variable in self.variables:
                result.add(variable.function)

        if self.actions:
            for action in self.actions:
                for frame in action.stack.frames:
                    result.add(frame.if_clause)
                    for datum in getattr(frame, 'datums', []):
                        result.add(datum.value)

        def _get_graph_config_xpaths(configuration):
            result = set()
            for config in configuration.configs:
                result.add(config.xpath_function)
            return result

        for field in self.fields:
            if field.template.form == 'graph':
                s = etree.tostring(field.template.node)
                template = load_xmlobject_from_string(s,
                                                      xmlclass=GraphTemplate)
                result.update(
                    _get_graph_config_xpaths(template.graph.configuration))
                for series in template.graph.series:
                    result.add(series.nodeset)
                    result.update(
                        _get_graph_config_xpaths(series.configuration))
            else:
                result.add(field.header.text.xpath_function)
                result.add(field.template.text.xpath_function)

        for detail in self.details:
            result.update(detail.get_all_xpaths())
        result.discard(None)
        return result
Ejemplo n.º 18
0
class QueryPrompt(DisplayNode):
    ROOT_NAME = 'prompt'

    key = StringField('@key')
Ejemplo n.º 19
0
class LocaleResource(AbstractResource):
    ROOT_NAME = 'locale'
    language = StringField('@language')
Ejemplo n.º 20
0
class RemoteRequestPost(XmlObject):
    ROOT_NAME = 'post'

    url = StringField('@url')
    relevant = StringField('@relevant')
    data = NodeListField('data', QueryData)
Ejemplo n.º 21
0
class Display(OrderedXmlObject):
    ROOT_NAME = 'display'
    ORDER = ('text', 'media_image', 'media_audio')
    text = NodeField('text', Text)
    media_image = StringField('media/@image')
    media_audio = StringField('media/@audio')
Ejemplo n.º 22
0
class LocaleArgument(XmlObject):
    ROOT_NAME = 'argument'
    key = StringField('@key')
    value = StringField('.')
Ejemplo n.º 23
0
class MediaText(XmlObject):
    ROOT_NAME = 'text'
    form_name = StringField('@form', choices=['image', 'audio'])  # Nothing XForm-y about this 'form'
    locale = NodeField('locale', LocaleId)
    xpath = NodeField('xpath', Xpath)
    xpath_function = XPathField('xpath/@function')
Ejemplo n.º 24
0
class AbstractTemplate(XmlObject):
    form = StringField('@form', choices=['image', 'phone', 'address'])
    width = IntegerField('@width')
    text = NodeField('text', Text)
Ejemplo n.º 25
0
class StackCommand(XmlObject):
    ROOT_NAME = 'command'

    value = XPathField('@value')
    command = StringField('.')
Ejemplo n.º 26
0
class Extra(XmlObject):
    ROOT_NAME = 'extra'

    key = StringField("@key")
    value = StringField("@value")
Ejemplo n.º 27
0
class ClearFrame(BaseFrame):
    ROOT_NAME = 'clear'

    frame = StringField('@frame')
Ejemplo n.º 28
0
class Response(XmlObject):
    ROOT_NAME = 'response'

    key = StringField("@key")
Ejemplo n.º 29
0
class QueryData(XmlObject):
    ROOT_NAME = 'data'

    key = StringField('@key')
    ref = XPathField('@ref')
Ejemplo n.º 30
0
class Instance(IdNode, OrderedXmlObject):
    ROOT_NAME = 'instance'
    ORDER = ('id', 'src')

    src = StringField('@src')