Commit 5d33cd54 authored by Markus Scheidgen's avatar Markus Scheidgen

Added metainfo python code.

parent fc60b6cf
......@@ -369,13 +369,15 @@ class AbstractBaseParser(with_metaclass(ABCMeta, object)):
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)
# self.super_backend.fileOut.write("[")
# uri = "file://" + self.parser_context.main_file
# self.backend.startedParsingSession(uri, self.parser_context.parser_info)
pass
def print_json_footer(self):
self.backend.finishedParsingSession("ParseSuccess", None)
self.super_backend.fileOut.write("]\n")
# self.backend.finishedParsingSession("ParseSuccess", None)
# self.super_backend.fileOut.write("]\n")
pass
@abstractmethod
def parse(self, filepath):
......@@ -432,7 +434,7 @@ class MainHierarchicalParser(AbstractBaseParser):
mainFileDescription=self.root_matcher,
metaInfoEnv=self.parser_context.metainfo_env,
parserInfo=self.parser_context.parser_info,
outF=self.parser_context.super_backend.fileOut,
# outF=self.parser_context.super_backend.fileOut,
cachingLevelForMetaName=self.caching_levels,
superContext=self.super_context,
onClose=self.on_close,
......
......@@ -272,7 +272,7 @@ class InfoKindEnv(object):
def addInfoKindEl(self, infoKind):
if infoKind.name in self.infoKinds and infoKind != self.infoKinds[infoKind.name]:
raise Exception('InfoKindEnv has collision for name {0}: {1} vs {2}'
.format(infoKind.name, infoKind, self.infoKinds[infoKind.name]))
.format(infoKind.name, infoKind.package, self.infoKinds[infoKind.name].package))
self.infoKinds[infoKind.name] = infoKind
def addDependenciesFrom(self, infoKindEnv):
......
......@@ -647,7 +647,7 @@ class CompiledMatcher(object):
target_unit = metainfo_unit
# If there is a dimension-specific unit conversion, use it
if metainfo_unit is None and parserBuilder.default_units is not None:
source_dim = unit_conversion.ureg(units).dimensionality
source_dim = unit_conversion.ureg(units).units.dimensionality
map_unit = parserBuilder.default_units.get(str(source_dim))
if map_unit:
target_unit = map_unit
......
......@@ -16,7 +16,10 @@ logger = logging.getLogger(__name__)
# disable warnings from pint
logging.getLogger("pint").setLevel(logging.ERROR)
ureg = UnitRegistry(os.path.join(os.path.dirname(__file__), "units.txt"))
# ureg = UnitRegistry(os.path.join(os.path.dirname(__file__), "units.txt"))
ureg = UnitRegistry()
ureg.define('forceAu = hartree / bohr')
ureg.define('inversecm = 1.9864475e-23 * joule')
_ureg_cache = dict()
......
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