From 17a0955efcdfc1e41cfc0de3680513d1b9d4eda2 Mon Sep 17 00:00:00 2001 From: Lauri Himanen <lauri.himanen@aalto.fi> Date: Wed, 7 Dec 2016 14:05:04 +0200 Subject: [PATCH] Added function to print out the JSON header and footer to the backend for parsers that don't use SimpleMatchers. --- common/python/nomadcore/baseclasses.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/python/nomadcore/baseclasses.py b/common/python/nomadcore/baseclasses.py index 127f4e9..46ad33b 100644 --- a/common/python/nomadcore/baseclasses.py +++ b/common/python/nomadcore/baseclasses.py @@ -346,6 +346,14 @@ class AbstractBaseParser(with_metaclass(ABCMeta, object)): default_units=self.parser_context.default_units, metainfo_units=self.parser_context.metainfo_units) + def print_json_header(self): + self.super_backend.fileOut.write("[") + uri = "file://" + self.parser_context.main_file + self.backend.startedParsingSession(uri, self.parser_context.parser_info) + + def print_json_footer(self): + self.super_backend.fileOut.write("]]\n") + @abstractmethod def parse(self): """Used to do the actual parsing. Inside this function you should push -- GitLab