Exemplo n.º 1
0
    def _read(self, filename=None, config=None, parse=True):
        "Reads and parses configuration input specified by kwds parameters"
        self.parser     = QEParser(filename, config, self._type)    #filename, config, type)
        (self.namelistRef, self.cardRef)    = self.parser.setReferences()

        if parse and (filename or config):
            QEInput.parse(self)     # Avoid calling method parse() from subclass

        self.qe = [self.header, self.namelists, self.cards, self.attach]
Exemplo n.º 2
0
 def __init__(self, filename=None, config=None, type='pw'):
     self.filename   = filename
     self.config     = config
     self.parser     = QEParser(filename, config, type)
     self.type       = type
     self.namelists  = OrderedDict()
     self.cards      = OrderedDict()
     self.attach     = None          # Specific for 'matdyn'
     self.namelistRef    = None
     self.cardRef        = None
     self.qe         = [self.namelists, self.cards, self.attach]
Exemplo n.º 3
0
 def test_qeparser_comments(self):
     # Filters out comments
     parser = QEParser(filename="ph.mgb2.in", type="ph")
     parser.parse()
     self.assertEqual(parser.toString(), fixtures.assertMgB2)
Exemplo n.º 4
0
 def test_qeparser_header(self):
     # Header for PH configuration files is mandatory
     parser = QEParser(configText=fixtures.textHeader, type="ph")
     parser.parse()
     self.assertEqual(parser.toString(), fixtures.assertHeader)
Exemplo n.º 5
0
 def test_qeparser_type(self):
     # Type of configuration file recognizes specific namelists and card only!
     parser = QEParser(configText=fixtures.textHeader, type="pw")
     parser.parse()
     self.assertEqual(parser.toString(),
                      '')  # namelist 'INPUTPH' is not recognized
Exemplo n.º 6
0
 def test_qeparser_comma(self):
     # Parameters on the same line separated by comma - does not parse as it
     # should (intentionally)
     parser = QEParser(configText=fixtures.textComma, type="matdyn")
     parser.parse()
     self.assertEqual(parser.toString(), fixtures.assertComma)
Exemplo n.º 7
0
 def test_qeparser_card(self):
     # Card
     parser = QEParser(configText=fixtures.textCards)
     parser.parse()
     self.assertEqual(parser.toString(), fixtures.assertCards)
Exemplo n.º 8
0
 def test_qeparser_file(self):
     # Configuration file
     parser = QEParser(filename="ni.scf.in")
     parser.parse()
     self.assertEqual(parser.toString(), fixtures.assertFile)
Exemplo n.º 9
0
 def test_qeparser_dynmat(self):
     # Slash and name of namelist on the same line with parameters
     parser = QEParser(configText=fixtures.textDynmat, type="dynmat")
     parser.parse()
     self.assertEqual(parser.toString(), fixtures.assertDynmat)
Exemplo n.º 10
0
 def test_qeparser_matdyn(self):
     # Attachment after card
     parser = QEParser(configText=fixtures.textMatdyn, type="matdyn")
     parser.parse()
     self.assertEqual(parser.toString(), fixtures.assertMatdyn)