Commit d8e1aaba authored by Mohamed, Fawzi Roberto (fawzi)'s avatar Mohamed, Fawzi Roberto (fawzi)
Browse files

h5Tool fixes (replacements, string decoding, lock removal, help printing)

parent 6af5d633
......@@ -149,7 +149,7 @@ object H5Tool extends StrictLogging {
val scanDirRe = "^--scan-dir=(.*)$".r
arg match {
case "--help" | "-h" =>
println(usage)
println(countCmdUsage)
return
case scanDirRe(dir) =>
scanDir = scanDir :+ Paths.get(dir)
......@@ -253,7 +253,7 @@ object H5Tool extends StrictLogging {
list = list.tail
arg match {
case "--help" | "-h" =>
println(usage)
println(renameCmdUsage)
return
case renamesRe(rFile) =>
replacements = replacements ++ Replacements.fromFile(Paths.get(rFile))
......@@ -281,6 +281,8 @@ object H5Tool extends StrictLogging {
if (!Files.exists(tPath.getParent))
Files.createDirectories(tPath.getParent, LocalEnv.directoryPermissionsAttributes)
Files.copy(inF, tPath, StandardCopyOption.REPLACE_EXISTING)
val lockFilePath = Paths.get(tPath.toString + ".lock")
Files.deleteIfExists(lockFilePath)
tPath
case None =>
inF
......
......@@ -1655,7 +1655,8 @@ lazy val h5Tool = (project in file("archive/h5-tool")).
settings(commonSettings: _*).
settings(
name := "h5Tool",
mainClass in assembly := Some("eu.nomad_lab.h5.H5Tool")
mainClass in assembly := Some("eu.nomad_lab.h5.H5Tool"),
javaOptions += ("-Djava.library.path=" + (baseDirectory.value / "../../hdf5/hdf5-support/lib").getCanonicalFile().toString())
).
settings(Revolver.settings: _*).
enablePlugins(BuildInfoPlugin).
......
......@@ -134,9 +134,13 @@ object JsonUtils {
def unescapeQuotedString(s: String): String = {
if (s.isEmpty || s(0) != '"')
throw new Exception(s"expected a string in double quotes, not '$s'")
parseStr(s) match {
case JString(res) => res
case v => throw new Exception(s"failed to parse a string, got '${normalizedStr(v)}'")
parseStr(s"[$s]") match {
case JArray(arr) =>
arr match {
case JString(res) :: Nil => res
case v => throw new Exception(s"failed to parse a string, got '${normalizedStr(JArray(v))}'")
}
case v => throw new Exception(s"failed to parse an array, got '${normalizedStr(v)}'")
}
}
......
......@@ -30,7 +30,7 @@ object Replacements {
val f = Source.fromFile(path.toFile, "UTF-8")
var metaPath: Option[Seq[String]] = None
val metaPathRe = """^#\s+([a-zA-Z0-9_/]+)\s*$""".r
val replPathRe = """^\s+("(?:[^\"]|\.)"|[+-a-zA-Z0-9]+)\s+->\s+("(?:[^\"]|\.)"|[+-a-zA-Z0-9]+)\s*$""".r
val replPathRe = """^\s+("(?:[^\"]|\\.)*"|[-+a-zA-Z0-9_]+)\s+->\s+("(?:[^\\"]|\\.)*"|[-+a-zA-Z0-9_]+)\s*$""".r
var repl: Map[String, String] = Map()
var res: Seq[Replacements] = Seq()
for (line <- f.getLines()) {
......
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