From a9f1a4e85398997a5515c169a5177f0724f77fd1 Mon Sep 17 00:00:00 2001 From: Alvin Noe Ladines <ladinesa@labdev-nomad.esc.rzg.mpg.de> Date: Thu, 17 Oct 2019 13:57:30 +0200 Subject: [PATCH] Added xz compression --- nomad/parsing/__init__.py | 4 ++-- nomad/parsing/parser.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/nomad/parsing/__init__.py b/nomad/parsing/__init__.py index 39f9f56fff..0481965589 100644 --- a/nomad/parsing/__init__.py +++ b/nomad/parsing/__init__.py @@ -71,7 +71,7 @@ based on NOMAD-coe's *python-common* module. :members: """ -from typing import Callable, IO, Union +from typing import Callable, IO, Union, Dict import magic import gzip import bz2 @@ -118,7 +118,7 @@ def match_parser(mainfile: str, upload_files: Union[str, files.StagingUploadFile with open(mainfile_path, 'rb') as f: compression, open_compressed = _compressions.get(f.read(3), (None, open)) - with open_compressed(mainfile_path, 'rb') as cf: + with open_compressed(mainfile_path, 'rb') as cf: # type: ignore buffer = cf.read(config.parser_matching_size) mime_type = magic.from_buffer(buffer, mime=True) diff --git a/nomad/parsing/parser.py b/nomad/parsing/parser.py index 3a57d79f58..2a04943350 100644 --- a/nomad/parsing/parser.py +++ b/nomad/parsing/parser.py @@ -139,8 +139,7 @@ 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') - print('DECODED',decoded_buffer) - except UnicodeDecodeError as e: + except UnicodeDecodeError: 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 -- GitLab