コード例 #1
0
def xml_out(qc, dest, stylesheet=None, indent=True):
    xqc = _xmlwrap.xml_quality_control()

    _xmldoc_out(xqc, qc)

    if isinstance(dest, basestring):
        fd = file(dest, "w")
    elif hasattr(dest, "write"):
        fd = dest
    else:
        raise TypeError, "invalid file object"

    try:
        filename = fd.name
    except AttributeError:
        filename = '<???>'

    fd.write('<?xml version="1.0" encoding="utf-8"?>\n')

    if stylesheet is not None:
        fd.write('<?xml-stylesheet type="application/xml" href="%s"?>\n' % \
            (stylesheet,))
    
    if indent is True:
        _indent(xqc._element)
    
    ET.ElementTree(xqc._element).write(fd, encoding="utf-8")
    
    if isinstance(dest, basestring):
        fd.close()
コード例 #2
0
    def close(self):
        root = self.__p.close()
        if root.tag != _root_tag:
            raise DBError, "unrecognized root element: " + root.tag

        xqc = _xmlwrap.xml_quality_control(root)
        _xmldoc_in(xqc, self.__qc)
コード例 #3
0
ファイル: qc.py プロジェクト: Fran89/seiscomp3
def xml_out(qc, dest, stylesheet=None, indent=True):
    xqc = _xmlwrap.xml_quality_control()

    _xmldoc_out(xqc, qc)

    if isinstance(dest, basestring):
        fd = file(dest, "w")
    elif hasattr(dest, "write"):
        fd = dest
    else:
        raise TypeError, "invalid file object"

    try:
        filename = fd.name
    except AttributeError:
        filename = '<???>'

    fd.write('<?xml version="1.0" encoding="utf-8"?>\n')

    if stylesheet != None:
        fd.write('<?xml-stylesheet type="application/xml" href="%s"?>\n' % \
            (stylesheet,))
    
    if indent is True:
        _indent(xqc._element)
    
    ET.ElementTree(xqc._element).write(fd, encoding="utf-8")
    
    if isinstance(dest, basestring):
        fd.close()
コード例 #4
0
ファイル: qc.py プロジェクト: Fran89/seiscomp3
    def close(self):
        root = self.__p.close()
        if root.tag != _root_tag:
            raise DBError, "unrecognized root element: " + root.tag

        xqc = _xmlwrap.xml_quality_control(root)
        _xmldoc_in(xqc, self.__qc)
コード例 #5
0
def xml_in(qc, src):
    doc = ET.parse(src)
    root = doc.getroot()
    if root.tag != _root_tag:
        raise DBError, "unrecognized root element: " + root.tag

    xqc = _xmlwrap.xml_quality_control(root)
    _xmldoc_in(xqc, qc)
コード例 #6
0
ファイル: qc.py プロジェクト: Fran89/seiscomp3
def xml_in(qc, src):
    doc = ET.parse(src)
    root = doc.getroot()
    if root.tag != _root_tag:
        raise DBError, "unrecognized root element: " + root.tag

    xqc = _xmlwrap.xml_quality_control(root)
    _xmldoc_in(xqc, qc)