From eae1e2d0d3b9b0d403ebc0c1ca1d4e1d14b7a140 Mon Sep 17 00:00:00 2001 From: Markus Scheidgen <markus.scheidgen@gmail.com> Date: Wed, 5 Sep 2018 09:37:32 +0200 Subject: [PATCH] Fixed aims main file re. --- nomad/parsing.py | 10 ++++++---- tests/misc.http | 2 +- tests/test_parsing.py | 9 ++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/nomad/parsing.py b/nomad/parsing.py index 0406a58299..73129c4233 100644 --- a/nomad/parsing.py +++ b/nomad/parsing.py @@ -602,7 +602,8 @@ class Parser(): file = None try: file = open(filename) - return self._main_contents_re.match(file.read(500)) is not None + contents = file.read(500) + return self._main_contents_re.match(contents) is not None finally: if file: file.close() @@ -674,10 +675,11 @@ parsers = [ Parser( python_git=dependencies['parsers/fhi-aims'], parser_class_name='fhiaimsparser.FHIaimsParser', - main_file_re=r'^.*\.out$', # TODO + main_file_re=r'^.*\.out$', main_contents_re=( - r'\s*Invoking FHI-aims \.\.\.\n' - r'\s*Version') + r'^(.*\n)*' + r'?\s*Invoking FHI-aims \.\.\.' + r'?\s*Version') ) ] """ Instanciation and constructor based config of all parsers. """ diff --git a/tests/misc.http b/tests/misc.http index 36e0f33e20..833644fbf4 100644 --- a/tests/misc.http +++ b/tests/misc.http @@ -6,5 +6,5 @@ POST http://enc-staging-nomad.esc.rzg.mpg.de/nomadxt/api/uploads HTTP/1.1 content-type: application/json { - "name": "RlVlpdRpKNozUtEx9dpD3E4Qc-_X4.zip" + "name": "aims-example-full" } diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 145a53636b..59deeb7060 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -212,15 +212,14 @@ def test_parser(parsed_example): def test_match(): - vasp_parser = parser_dict['parsers/vasp'] directory = 'tests/data/proc/match' count = 0 for dirpath, _, filenames in os.walk(directory): for filename in filenames: fullname = os.path.join(dirpath, filename) - if vasp_parser.is_mainfile(fullname, lambda fn: open(fn)): - print(fullname) - count += 1 + for parser in parser_dict.values(): + if parser.is_mainfile(fullname, lambda fn: open(fn)): + count += 1 - assert count == 5 + assert count == 6 -- GitLab