processing published entries fails when using encoding keyword
In https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-FAIR/-/blob/develop/nomad/files.py#L1783
we have
f = zf.open(file_path, 'r', **kwargs)
when using: with archive.m_context.raw_file(self.data_file, encoding=encoding) as f:
this fails since encoding is not a valid argument to zipfile.open
possibleidea:
def raw_file(self, file_path: str, *args, **kwargs) -> IO:
assert is_safe_relative_path(file_path)
mode = kwargs.get('mode') if len(args) == 0 else args[0]
encoding = kwargs.get('encoding')
if 'mode' in kwargs:
del kwargs['mode']
if 'encoding' in kwargs:
del kwargs['encoding']
mode = mode if mode else 'rb'
try:
zf = self._open_raw_zip_file()
f = zf.open(file_path, 'r', **kwargs)
if 't' in mode:
return io.TextIOWrapper(f, encoding=encoding)
else:
return f
except FileNotFoundError:
pass
except IsADirectoryError:
pass
except KeyError:
pass
raise KeyError(file_path)
Edited by Michael Götte