File: RoutineReference.py

package info (click to toggle)
python-fontfeatures 1.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,096 kB
  • sloc: python: 9,112; makefile: 22
file content (17 lines) | stat: -rw-r--r-- 457 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Routines for converting RoutineReference objects to and from XML."""
from lxml import etree


def toXML(self):
    """Serializes a RoutineReference to a lxml Element object."""
    root = etree.Element("routinereference")
    if self.name:
        root.attrib["name"] = self.name
    return root


@classmethod
def fromXML(klass, el):
    """Creates a RoutineReference from a lxml Element object."""
    rule = klass(name=el.get("name"))
    return rule