Example #1
0
    def test(self):
        tree = ElementTree.parse(xml_file)
        root = tree.getroot()

        element_name = root.tag.split('}')[-1]

        if element_name == 'espresso':
            xml_conf = qeschema.PwDocument(source=xml_file)
        elif element_name == 'nebRun':
            xml_conf = qeschema.NebDocument(source=xml_file)
        elif element_name == 'espressoph':
            xml_conf = qeschema.PhononDocument(source=xml_file)
        elif element_name == 'tddfpt':
            xml_conf = qeschema.TdDocument(source=xml_file)
        elif element_name == 'spectrumDoc':
            xml_conf = qeschema.TdSpectrumDocument(source=xml_file)
        else:
            raise ValueError(
                "XML file %r is not a Quantum ESPRESSO document!" % xml_file)

        xml_conf.read(xml_file)
        qe_input = xml_conf.get_fortran_input().split('\n')
        with open(ref_in_file, 'r') as qe_input_file:
            k = 0
            are_equals = True
            for ref_line in qe_input_file:
                ref_line = ref_line.rstrip('\n').strip(' \t')
                in_line = qe_input[k].strip(' \t')
                if ref_line != in_line:
                    print("Unmatched lines: '%s' != '%s'" %
                          (in_line, ref_line))
                    are_equals = False
                    break
                else:
                    k += 1
        self.assertTrue(are_equals, xml_file)
Example #2
0
    import xml.etree.ElementTree as Etree

    qeschema.set_logger(args.verbosity)

    input_fn = getattr(args, 'in')
    tree = Etree.parse(input_fn)
    root = tree.getroot()
    element_name = root.tag.split('}')[-1]
    if element_name == 'espresso':
        xml_document = qeschema.PwDocument()
    elif element_name == 'nebRun':
        xml_document = qeschema.NebDocument()
    elif element_name == 'espressoph':
        xml_document = qeschema.PhononDocument()
    elif element_name == 'tddfpt':
        xml_document = qeschema.TdDocument()
    elif element_name == 'spectrumDoc':
        xml_document = qeschema.TdSpectrumDocument()
    else:
        sys.stderr.write("Could not find correct XML in %s, exiting...\n" %
                         input_fn)
        sys.exit(1)

    root = None
    tree = None

    xml_document.read(input_fn)
    qe_in = xml_document.get_fortran_input()

    input_fn_name, input_fn_ext = os.path.splitext(input_fn)
    outfile = input_fn_name + '.in'
Example #3
0
    import xml.etree.ElementTree as Etree

    qeschema.set_logger(args.verbosity)

    input_fn = getattr(args, 'in')
    tree = Etree.parse(input_fn)
    root = tree.getroot()
    elementName = root.tag.split('}')[-1]
    if elementName == 'espresso':
        xml_conf = qeschema.PwDocument()
    elif elementName == 'nebRun':
        xml_conf = qeschema.NebDocument()
    elif elementName == 'espressoph':
        xml_conf = qeschema.PhononDocument()
    elif elementName == 'tddfpt':
        xml_conf = qeschema.TdDocument()
    elif elementName == 'spectrumDoc':
        xml_conf = qeschema.SpectrumDocument()
    else:
        sys.stderr.write("Could not find correct XML in %s, exiting...\n" %
                         input_fn)
        sys.exit(1)

    root = None
    tree = None

    xml_conf.read(input_fn)
    qe_in = xml_conf.get_qe_input()

    input_fn_name, input_fn_ext = os.path.splitext(input_fn)
    outfile = input_fn_name + '.in'