Commit 4145ff7d authored by Daria M. Tomecka's avatar Daria M. Tomecka
Browse files

fixing scala wrapper

parent 38c49f7b
......@@ -7,17 +7,24 @@ import scala.collection.breakOut
import eu.nomad_lab.normalize.ExternalNormalizerGenerator
import eu.nomad_lab.meta
import eu.nomad_lab.query
import eu.nomad_lab.resolve._
import eu.nomad_lab.h5.EmitJsonVisitor
import eu.nomad_lab.h5.H5EagerScanner
import eu.nomad_lab.h5.SectionH5
import eu.nomad_lab.parsers.ExternalParserWrapper
import eu.nomad_lab.JsonUtils
import scala.collection.mutable.StringBuilder
object PrototypeNormalizer extends ExternalNormalizerGenerator(
name = "PrototypeNormalizer",
object PrototypesNormalizer extends ExternalNormalizerGenerator(
name = "PrototypesNormalizer",
info = jn.JObject(
("name" -> jn.JString("PrototypeNormalizer")) ::
("normalizerId" -> jn.JString("PrototypeNormalizer" + lab.PrototypeVersionInfo.version)) ::
("name" -> jn.JString("PrototypesNormalizer")) ::
("normalizerId" -> jn.JString("PrototypesNormalizer" + lab.PrototypesVersionInfo.version)) ::
("versionInfo" -> jn.JObject(
("nomadCoreVersion" -> jn.JObject(lab.NomadCoreVersionInfo.toMap.map {
case (k, v) => k -> jn.JString(v.toString)
}(breakOut): List[(String, jn.JString)])) ::
(lab.PrototypeVersionInfo.toMap.map {
(lab.PrototypesVersionInfo.toMap.map {
case (key, value) =>
(key -> jn.JString(value.toString))
}(breakOut): List[(String, jn.JString)])
......@@ -42,7 +49,7 @@ object PrototypeNormalizer extends ExternalNormalizerGenerator(
) ++ DefaultPythonInterpreter.commonDirMapping(),
metaInfoEnv = lab.meta.KnownMetaInfoEnvs.all
) {
val trace: Boolean = false
val trace: Boolean = true
override def stdInHandler(context: ResolvedRef)(wrapper: ExternalParserWrapper)(pIn: java.io.OutputStream): Unit = {
val out: java.io.Writer = if (trace)
......@@ -66,9 +73,9 @@ object PrototypeNormalizer extends ExternalNormalizerGenerator(
try {
context match {
case Calculation(archiveSet, c) =>
val sysTable = c.sectionTable(Seq("section_run", "section_system"))
def outputSysSection(sysSection: SectionH5): Unit = {
val sysTable = c.sectionTable(Seq("section_run", "section_system"))
def outputSysSection(sysSection: SectionH5): Unit = {
if (!isFirst)
writeOut(",")
else
......@@ -83,14 +90,13 @@ object PrototypeNormalizer extends ExternalNormalizerGenerator(
scanner.scanResolvedRef(Section(archiveSet, sysSection), visitor)
//writeOut("}")
flush()
}
}
val nSys = sysTable.lengthL
if (nSys > 0)
outputSysSection(sysTable(0))
if (nSys > 1)
outputSysSection(sysTable(nSys - 1))
val nSys = sysTable.lengthL
if (nSys > 0)
outputSysSection(sysTable(0))
if (nSys > 1)
outputSysSection(sysTable(nSys - 1))
writeOut("]")
flush()
......
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