Commit ab9ce80c authored by Ask Hjorth Larsen's avatar Ask Hjorth Larsen
Browse files

remove other unused module

parent f1ee8be9
from nomadcore.simple_parser import mainFunction, runParser
OCT_ENERGY_UNIT_NAME = 'usrOctEnergyUnit'
f_num = r'[-+]?(\d*\.\d+|\d+\.\d*)' # e.g.: 0.7 1. -.1
e_num = r'[-+]?\d*\.\d+[EeDd][-+]\d*' # e.g.: -7.642e-300
i_num = r'[-+\d]*'
def numpattern(id, unit=None, pattern=f_num):
if unit is None:
pat = r'(?P<%(id)s>%(pattern)s)'
pat = r'(?P<%(id)s__%(unit)s>%(pattern)s)'
return pat % dict(id=id, unit=unit, pattern=pattern)
def pat(meta, regex):
return '(?P<%s>%s)' % (meta, regex)
def word(meta):
return pat(meta, regex=r'\S*')
def integer(meta):
return pat(meta, regex=i_num)
def floating(meta):
return pat(meta, regex='%s|%s' % (f_num, e_num))
def parse_file_without_decorations(pew, meta_info_env, matchers,
parser_info, supercontext, fname):
"""Run SimpleMatcher on a file printing only sequence of json."""
# If we set outF, it only redirects some of the stuff.
# It writes "[" followed by json followed by "]", to
# different streams. By redirecting one of them we can get only
# the json. Strange but true!
class DevNull:
def write(self, txt):
# This is to prevent another header (nomad_parse_events_1_0 etc.)
def parsefile(parser_builder, uri, path, backend, super_context):
with open(path) as fd:
runParser(parser_builder, backend, super_context, fd)
outF=DevNull(), # Eats surrounding []
Copyright 2016-2017 The NOMAD Developers Group
Copyright 2016-2018 The NOMAD Developers Group
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -49,7 +49,6 @@ Simulation Box:
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