Commit 67c887c3 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Test and fix for parrallel outcar/xml matching.

parent 9d62d827
......@@ -94,7 +94,8 @@ def match_parser(mainfile: str, upload_files: files.StagingUploadFiles) -> 'Pars
with upload_files.raw_file(mainfile, 'rb') as f:
compression, open_compressed = _compressions.get(, (None, open))
with open_compressed(upload_files.raw_file_object(mainfile).os_path, 'rb') as f:
mainfile_path = upload_files.raw_file_object(mainfile).os_path
with open_compressed(mainfile_path, 'rb') as f:
buffer =
mime_type = magic.from_buffer(buffer, mime=True)
......@@ -102,7 +103,7 @@ def match_parser(mainfile: str, upload_files: files.StagingUploadFiles) -> 'Pars
return None
for parser in parsers:
if parser.is_mainfile(mainfile, mime_type, buffer.decode('utf-8'), compression):
if parser.is_mainfile(mainfile_path, mime_type, buffer.decode('utf-8'), compression):
return parser
return None
......@@ -35,7 +35,15 @@ class Parser(metaclass=ABCMeta):
def is_mainfile(self, filename: str, mime: str, buffer: str, compression: str = None) -> bool:
""" Checks if a file is a mainfile for the parsers. """
Checks if a file is a mainfile for the parsers.
filename: The filesystem path to the mainfile
mime: The mimetype of the mainfile guessed with libmagic
buffer: The first 2k of the mainfile contents
compression: The compression of the mainfile ``[None, 'gz', 'bz2']``
......@@ -136,8 +144,8 @@ class VaspOutcarParser(LegacyParser):
is_mainfile = super().is_mainfile(filename, *args, **kwargs)
if is_mainfile:
if len(glob.glob('%s/*.xml*' % filename)) > 0:
directory = os.path.dirname(filename)
if len(glob.glob('%s/*.xml*' % directory)) > 0:
return False
return is_mainfile
This diff is collapsed.
This diff is collapsed.
......@@ -46,7 +46,7 @@ faulty_unknown_one_d_matid_example = [
('parsers/template', 'tests/data/normalizers/no_sim_cell_boolean_positions.json')
correct_num_output_files = 17
correct_num_output_files = 18
class TestLocalBackend(object):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment