Пример #1
0
    def toeeml(self):
        """
        Convert this element into a DOM object.

        :return: a data element
        :rtype: `Element`
        """

        data = _elem('data')

        _addA(data, self._id, 'id', str)
        for tag in self._tags:
            _addE(data, tag, 'tag')

        if self._value is not None:
            tmp = _elem('current_value')
            _addA(tmp, self._minValue, 'minValue', str)
            _addA(tmp, self._maxValue, 'maxValue', str)
            _addA(tmp, self._at, 'at', lambda x: x.isoformat())
            tmp.text = str(self._value)
            data.append(tmp)

        if self._unit is not None:
            data.append(self._unit.toeeml())

        if self._datapoints is not None:
            data.append(self._datapoints.toeeml())
            
        return data
Пример #2
0
    def toeeml(self):
        """
        Convert this element into a DOM object.

        :return: a data element
        :rtype: `Element`
        """

        data = _elem('data')

        _addA(data, self._id, 'id', str)
        for tag in self._tags:
            _addE(data, tag, 'tag')

        if self._value is not None:
            tmp = _elem('current_value')
            _addA(tmp, self._minValue, 'minValue', str)
            _addA(tmp, self._maxValue, 'maxValue', str)
            _addA(tmp, self._at, 'at', lambda x: x.isoformat())
            tmp.text = str(self._value)
            data.append(tmp)

        if self._unit is not None:
            data.append(self._unit.toeeml())

        if self._datapoints is not None:
            data.append(self._datapoints.toeeml())

        return data
Пример #3
0
    def toeeml(self):
        """
        Convert this element into a DOM object.

        :return: a data element
        :rtype: `Element`
        """

        data = _elem("data")

        _addA(data, self._id, "id", str)
        for tag in self._tags:
            _addE(data, tag, "tag")

        if self._value is not None:
            tmp = _elem("current_value")
            _addA(tmp, self._minValue, "minValue", str)
            _addA(tmp, self._maxValue, "maxValue", str)
            _addA(tmp, self._at, "at", lambda x: x.isoformat())
            tmp.text = str(self._value)
            data.append(tmp)

        if self._unit is not None:
            data.append(self._unit.toeeml())

        if self._datapoints is not None:
            data.append(self._datapoints.toeeml())

        return data
Пример #4
0
    def toeeml(self):
        """
        Convert this file into eeml format.

        :return: the top element of this `Environment`
        :rtype: `Element`
        """
        env = _elem('environment')
        if isinstance(self._updated, (
                date,
                datetime,
        )):
            _addA(env, self._updated, 'updated', lambda x: x.isoformat())
        elif self._updated is not None:
            _addA(env, self._updated, 'updated')
        _addA(env, self._creator, 'creator')
        _addA(env, self._id, 'id', str)
        _addE(env, self._title, 'title')
        _addE(env, self._feed, 'feed')
        _addE(env, self._status, 'status')
        _addE(env, self._description, 'description')
        _addE(env, self._icon, 'icon')
        _addE(env, self._website, 'website')
        _addE(env, self._email, 'email')
        _addE(env, self._private, 'private', lambda x: str(x).lower())
        if self._location is not None:
            env.append(self._location.toeeml())
        for (dataId, data) in self._data.iteritems():
            env.append(data.toeeml())
        return env
Пример #5
0
    def toeeml(self):
        """
        Convert this file into eeml format.

        :return: the top element of this `Environment`
        :rtype: `Element`
        """
        env = _elem("environment")
        if isinstance(self._updated, (date, datetime)):
            _addA(env, self._updated, "updated", lambda x: x.isoformat())
        elif self._updated is not None:
            _addA(env, self._updated, "updated")
        _addA(env, self._creator, "creator")
        _addA(env, self._id, "id", str)
        _addE(env, self._title, "title")
        _addE(env, self._feed, "feed")
        _addE(env, self._status, "status")
        _addE(env, self._description, "description")
        _addE(env, self._icon, "icon")
        _addE(env, self._website, "website")
        _addE(env, self._email, "email")
        _addE(env, self._private, "private", lambda x: str(x).lower())
        if self._location is not None:
            env.append(self._location.toeeml())
        for data in self._data:
            env.append(data.toeeml())
        return env
Пример #6
0
    def toeeml(self):
        """
        Convert this file into eeml format.

        :return: the top element of this `Environment`
        :rtype: `Element`
        """
        env = _elem('environment')
        if isinstance(self._updated, (date, datetime,)):
            _addA(env, self._updated, 'updated', lambda x: x.isoformat())
        elif self._updated is not None:
            _addA(env, self._updated, 'updated')
        _addA(env, self._creator, 'creator')
        _addA(env, self._id, 'id', str)
        _addE(env, self._title, 'title')
        _addE(env, self._feed, 'feed')
        _addE(env, self._status, 'status')
        _addE(env, self._description, 'description')
        _addE(env, self._icon, 'icon')
        _addE(env, self._website, 'website')
        _addE(env, self._email, 'email')
        _addE(env, self._private, 'private', lambda x: str(x).lower())
        if self._location is not None:
            env.append(self._location.toeeml())
        for (dataId, data) in self._data.iteritems():
            env.append(data.toeeml())
        return env
Пример #7
0
def _addE(env, attr, name, call=lambda x: x):
    """
    Helper method to add child if not None
    """
    if attr is not None:
        tmp = _elem(name)
        tmp.text = call(attr)
        env.append(tmp)
Пример #8
0
def _addE(env, attr, name, call=lambda x: x):
    """
    Helper method to add child if not None
    """
    if attr is not None:
        tmp = _elem(name)
        tmp.text = call(attr)
        env.append(tmp)
Пример #9
0
    def toeeml(self):
        """
        Convert this element into a DOM object.

        :return: a data element
        :rtype: `Element`
        """

        data = _elem('datapoints')

        for pair in self._values:
            tmp = _elem('value')
            tmp.text = str(pair[0])
            if len(pair) > 1:
                tmp.attrib['at'] = pair[1].isoformat()
            data.append(tmp)

        return data
Пример #10
0
    def toeeml(self):
        """
        Convert this element into a DOM object.

        :return: a data element
        :rtype: `Element`
        """

        data = _elem("datapoints")

        for pair in self._values:
            tmp = _elem("value")
            tmp.text = str(pair[0])
            if len(pair) > 1:
                tmp.attrib["at"] = pair[1].isoformat()
            data.append(tmp)

        return data
Пример #11
0
    def toeeml(self):
        """
        Convert this document into an EEML file.

        :return: the EEML document
        :rtype: `Document`
        """
        eeml = _elem('eeml')

        eeml.attrib[SCHEMA_LOCATION[0]] = SCHEMA_LOCATION[1]
        eeml.attrib['version'] = EEML_SCHEMA_VERSION

        eeml.append(self._environment.toeeml())

        return eeml
Пример #12
0
    def toeeml(self):
        """
        Convert this document into an EEML file.

        :return: the EEML document
        :rtype: `Document`
        """
        eeml = _elem("eeml")

        eeml.attrib[SCHEMA_LOCATION[0]] = SCHEMA_LOCATION[1]
        eeml.attrib["version"] = EEML_SCHEMA_VERSION

        eeml.append(self._environment.toeeml())

        return eeml
Пример #13
0
    def toeeml(self):
        """
        Convert this object into a DOM element.

        :return: the unit element
        :rtype: `Element`
        """

        unit = _elem('unit')

        _addA(unit, self._type, 'type')
        _addA(unit, self._symbol, 'symbol')

        unit.text = self._name

        return unit
Пример #14
0
    def toeeml(self):
        """
        Convert this class into a EEML DOM element.

        :return: the location element
        :rtype: `Element`
        """

        loc = _elem('location')

        _addA(loc, self._exposure, 'exposure')
        _addA(loc, self._domain, 'domain')
        _addA(loc, self._disposition, 'disposition')
        _addE(loc, self._name, 'name')
        _addE(loc, self._lat, 'lat', str)
        _addE(loc, self._lon, 'lon', str)
        _addE(loc, self._ele, 'ele', str)

        return loc
Пример #15
0
    def toeeml(self):
        """
        Convert this class into a EEML DOM element.

        :return: the location element
        :rtype: `Element`
        """

        loc = _elem("location")

        _addA(loc, self._exposure, "exposure")
        _addA(loc, self._domain, "domain")
        _addA(loc, self._disposition, "disposition")
        _addE(loc, self._name, "name")
        _addE(loc, self._lat, "lat", str)
        _addE(loc, self._lon, "lon", str)
        _addE(loc, self._ele, "ele", str)

        return loc
Пример #16
0
    def toeeml(self):
        """
        Convert this class into a EEML DOM element.

        :return: the location element
        :rtype: `Element`
        """

        loc = _elem('location')

        _addA(loc, self._exposure, 'exposure')
        _addA(loc, self._domain, 'domain')
        _addA(loc, self._disposition, 'disposition')
        _addE(loc, self._name, 'name')
        _addE(loc, self._lat, 'lat', str)
        _addE(loc, self._lon, 'lon', str)
        _addE(loc, self._ele, 'ele', str)

        return loc