Commit a1c76ed1 authored by Alvin Noe Ladines's avatar Alvin Noe Ladines
Browse files

Added xz compression

parent 5742383c
Pipeline #62087 canceled with stages
in 1 minute and 27 seconds
Subproject commit dc59aff14e69a6818fbefeb7b1d504348438e26b
Subproject commit 7d850bd76e878b1429d6974f5daac456099f6e4f
......@@ -75,6 +75,7 @@ from typing import Callable, IO, Union
import magic
import gzip
import bz2
import lzma
import os.path
from nomad import files, config
......@@ -87,7 +88,8 @@ from nomad.parsing.artificial import TemplateParser, GenerateRandomParser, Chaos
_compressions = {
b'\x1f\x8b\x08': ('gz', gzip.open),
b'\x42\x5a\x68': ('bz2', bz2.open)
b'\x42\x5a\x68': ('bz2', bz2.open),
b'\xfd\x37\x7a': ('xz', lzma.open)
}
......@@ -147,14 +149,14 @@ parsers = [
LegacyParser(
name='parsers/vasp', code_name='VASP',
parser_class_name='vaspparser.VASPRunParserInterface',
mainfile_mime_re=r'(application/xml)|(text/.*)',
mainfile_mime_re=r'(application/.*)|(text/.*)',
mainfile_contents_re=(
r'^\s*<\?xml version="1\.0" encoding="ISO-8859-1"\?>\s*'
r'?\s*<modeling>'
r'?\s*<generator>'
r'?\s*<i name="program" type="string">\s*vasp\s*</i>'
r'?'),
supported_compressions=['gz', 'bz2']
supported_compressions=['gz', 'bz2', 'xz']
),
VaspOutcarParser(
name='parsers/vasp-outcar', code_name='VASP',
......
......@@ -139,7 +139,8 @@ class MatchingParser(Parser):
if self._mainfile_contents_re is not None:
try: # Try to open the file as a string for regex matching.
decoded_buffer = buffer.decode('utf-8')
except UnicodeDecodeError:
print('DECODED',decoded_buffer)
except UnicodeDecodeError as e:
return False # We're looking for a string match in a file that can't be converted to string.
if self._mainfile_contents_re.search(decoded_buffer) is None:
return False
......
Markdown is supported
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