From 179c4ce3e0990b431869a7d644590689e91f8fe2 Mon Sep 17 00:00:00 2001
From: speckhard <dts@stanford.edu>
Date: Tue, 5 Feb 2019 15:57:15 +0100
Subject: [PATCH] Removed scala infrastructure.

---
 nwchemparser/parser.py                        | 28 +++-----
 nwchemparser/scalainterface.py                | 31 ---------
 nwchemparser/setup_paths.py                   | 31 ---------
 nwchemparser/versions/nwchem66/mainparser.py  |  6 +-
 .../eu/nomad_lab/parsers/NWChemParser.scala   | 67 -------------------
 .../nomad_lab/parsers/NWChemParserSpec.scala  | 39 -----------
 6 files changed, 12 insertions(+), 190 deletions(-)
 delete mode 100644 nwchemparser/scalainterface.py
 delete mode 100644 nwchemparser/setup_paths.py
 delete mode 100644 src/main/scala/eu/nomad_lab/parsers/NWChemParser.scala
 delete mode 100644 src/test/scala/eu/nomad_lab/parsers/NWChemParserSpec.scala

diff --git a/nwchemparser/parser.py b/nwchemparser/parser.py
index 89d2c1d..8ffcf9b 100644
--- a/nwchemparser/parser.py
+++ b/nwchemparser/parser.py
@@ -14,6 +14,8 @@
 
 # from builtins import next
 # from builtins import range
+from builtins import next
+from builtins import range
 import os
 import re
 import logging
@@ -30,20 +32,8 @@ class NWChemParser(ParserInterface):
     After the implementation has been setup, you can parse the files with
     parse().
     """
-    def __init__(
-        self, metainfo_to_keep=None, backend=None, default_units=None,
-        metainfo_units=None, debug=True, logger = None,
-        log_level=logging.ERROR, store=True
-    ):
-        super(NWChemParser, self).__init__(
-            metainfo_to_keep, backend, default_units,
-            metainfo_units, debug, log_level, store
-        )
-        if logger is not None:
-            self.logger = logger
-            self.logger.debug('received logger')
-        else:
-            self.logger = logging.getLogger(__name__)
+    def __init__(self, metainfo_to_keep=None, backend=None, default_units=None, metainfo_units=None, debug=True, log_level=logging.ERROR, store=True):
+        super(NWChemParser, self).__init__(metainfo_to_keep, backend, default_units, metainfo_units, debug, log_level, store)
 
     def setup_version(self):
         """Setups the version by looking at the output file and the version
@@ -62,7 +52,7 @@ class NWChemParser(ParserInterface):
 
         if version_id is None:
             msg = "Could not find a version specification from the given main file."
-            self.logger.exception(msg)
+            logger.exception(msg)
             raise RuntimeError(msg)
 
         # Setup the root folder to the fileservice that is used to access files
@@ -90,16 +80,16 @@ class NWChemParser(ParserInterface):
         try:
             parser_module = importlib.import_module(base)
         except ImportError:
-            self.logger.warning("Could not find a parser for version '{}'. Trying to default to the base implementation for NWChem 6.6".format(version_id))
+            logger.warning("Could not find a parser for version '{}'. Trying to default to the base implementation for NWChem 6.6".format(version_id))
             base = "nwchemparser.versions.nwchem66.mainparser"
             try:
                 parser_module = importlib.import_module(base)
             except ImportError:
-                self.logger.exception("Tried to default to the NWChem 6.6 implementation but could not find the correct module.")
+                logger.exception("Tried to default to the NWChem 6.6 implementation but could not find the correct module.")
                 raise
         try:
             parser_class = getattr(parser_module, "NWChemMainParser")
         except AttributeError:
-            self.logger.exception("A parser class 'NWChemMainParser' could not be found in the module '[]'.".format(parser_module))
+            logger.exception("A parser class 'NWChemMainParser' could not be found in the module '[]'.".format(parser_module))
             raise
-        self.main_parser = parser_class(self.parser_context)
+        self.main_parser = parser_class(self.parser_context)
\ No newline at end of file
diff --git a/nwchemparser/scalainterface.py b/nwchemparser/scalainterface.py
deleted file mode 100644
index 234c837..0000000
--- a/nwchemparser/scalainterface.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2016-2018 Lauri Himanen, Fawzi Mohamed
-# 
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-# 
-#     http://www.apache.org/licenses/LICENSE-2.0
-# 
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-
-"""
-This is the access point to the parser for the scala layer in the
-nomad project.
-"""
-from __future__ import absolute_import
-import sys
-import setup_paths
-from nomadcore.parser_backend import JsonParseEventsWriterBackend
-from nwchemparser import NWChemParser
-
-
-if __name__ == "__main__":
-
-    # Initialise the parser with the main filename and a JSON backend
-    main_file = sys.argv[1]
-    parser = NWChemParser(backend=JsonParseEventsWriterBackend)
-    parser.parse(main_file)
diff --git a/nwchemparser/setup_paths.py b/nwchemparser/setup_paths.py
deleted file mode 100644
index 8afd151..0000000
--- a/nwchemparser/setup_paths.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2016-2018 Lauri Himanen, Fawzi Mohamed
-# 
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-# 
-#     http://www.apache.org/licenses/LICENSE-2.0
-# 
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-
-"""
-Setups the python-common library in the PYTHONPATH system variable.
-"""
-import sys
-import os
-import os.path
-
-baseDir = os.path.dirname(os.path.abspath(__file__))
-commonDir = os.path.normpath(os.path.join(baseDir, "../../../../../python-common/common/python"))
-parserDir = os.path.normpath(os.path.join(baseDir, "../../parser-nwchem"))
-
-# Using sys.path.insert(1, ...) instead of sys.path.insert(0, ...) based on
-# this discusssion:
-# http://stackoverflow.com/questions/10095037/why-use-sys-path-appendpath-instead-of-sys-path-insert1-path
-if commonDir not in sys.path:
-    sys.path.insert(1, commonDir)
-    sys.path.insert(1, parserDir)
diff --git a/nwchemparser/versions/nwchem66/mainparser.py b/nwchemparser/versions/nwchem66/mainparser.py
index f068542..81670eb 100644
--- a/nwchemparser/versions/nwchem66/mainparser.py
+++ b/nwchemparser/versions/nwchem66/mainparser.py
@@ -1,11 +1,11 @@
 # Copyright 2016-2018 Lauri Himanen, Fawzi Mohamed
-# 
+#
 #   Licensed under the Apache License, Version 2.0 (the "License");
 #   you may not use this file except in compliance with the License.
 #   You may obtain a copy of the License at
-# 
+#
 #     http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 #   Unless required by applicable law or agreed to in writing, software
 #   distributed under the License is distributed on an "AS IS" BASIS,
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/main/scala/eu/nomad_lab/parsers/NWChemParser.scala b/src/main/scala/eu/nomad_lab/parsers/NWChemParser.scala
deleted file mode 100644
index ddcc23d..0000000
--- a/src/main/scala/eu/nomad_lab/parsers/NWChemParser.scala
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2016-2018 Lauri Himanen, Fawzi Mohamed
- * 
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- */
-
-package eu.nomad_lab.parsers
-
-import eu.{ nomad_lab => lab }
-import eu.nomad_lab.DefaultPythonInterpreter
-import org.{ json4s => jn }
-import scala.collection.breakOut
-
-object NWChemParser extends SimpleExternalParserGenerator(
-  name = "NWChemParser",
-  parserInfo = jn.JObject(
-    ("name" -> jn.JString("NWChemParser")) ::
-      ("parserId" -> jn.JString("NWChemParser" + lab.NwchemVersionInfo.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.NwchemVersionInfo.toMap.map {
-            case (key, value) =>
-              (key -> jn.JString(value.toString))
-          }(breakOut): List[(String, jn.JString)])
-      )) :: Nil
-  ),
-  mainFileTypes = Seq("text/.*"),
-  mainFileRe = """              Northwest Computational Chemistry Package \(NWChem\) \d+\.\d+
-              ------------------------------------------------------
-
-
-                    Environmental Molecular Sciences Laboratory
-                       Pacific Northwest National Laboratory
-                                Richland, WA 99352""".r,
-  cmd = Seq(DefaultPythonInterpreter.pythonExe(), "${envDir}/parsers/nwchem/parser/parser-nwchem/nwchemparser/scalainterface.py",
-    "${mainFilePath}"),
-  cmdCwd = "${mainFilePath}/..",
-  resList = Seq(
-    "parser-nwchem/nwchemparser/__init__.py",
-    "parser-nwchem/nwchemparser/setup_paths.py",
-    "parser-nwchem/nwchemparser/parser.py",
-    "parser-nwchem/nwchemparser/scalainterface.py",
-    "parser-nwchem/nwchemparser/versions/__init__.py",
-    "parser-nwchem/nwchemparser/versions/nwchem66/__init__.py",
-    "parser-nwchem/nwchemparser/versions/nwchem66/mainparser.py",
-    "nomad_meta_info/public.nomadmetainfo.json",
-    "nomad_meta_info/common.nomadmetainfo.json",
-    "nomad_meta_info/meta_types.nomadmetainfo.json",
-    "nomad_meta_info/nwchem.nomadmetainfo.json"
-  ) ++ DefaultPythonInterpreter.commonFiles(),
-  dirMap = Map(
-    "parser-nwchem" -> "parsers/nwchem/parser/parser-nwchem",
-    "nomad_meta_info" -> "nomad-meta-info/meta_info/nomad_meta_info"
-  ) ++ DefaultPythonInterpreter.commonDirMapping()
-)
diff --git a/src/test/scala/eu/nomad_lab/parsers/NWChemParserSpec.scala b/src/test/scala/eu/nomad_lab/parsers/NWChemParserSpec.scala
deleted file mode 100644
index 159e1e2..0000000
--- a/src/test/scala/eu/nomad_lab/parsers/NWChemParserSpec.scala
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-2018 Lauri Himanen, Fawzi Mohamed
- * 
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- */
-
-package eu.nomad_lab.parsers
-
-import org.specs2.mutable.Specification
-
-object NWChemParserSpec extends Specification {
-  "NWChemParserTest" >> {
-    "test with json-events" >> {
-      ParserRun.parse(NWChemParser, "parsers/nwchem/test/examples/single_point/output.out", "json-events") must_== ParseResult.ParseSuccess
-    }
-  }
-
-  "test single_point with json" >> {
-    ParserRun.parse(NWChemParser, "parsers/nwchem/test/examples/single_point/output.out", "json") must_== ParseResult.ParseSuccess
-  }
-
-  "test geo_opt with json" >> {
-    ParserRun.parse(NWChemParser, "parsers/nwchem/test/examples/geo_opt/output.out", "json") must_== ParseResult.ParseSuccess
-  }
-
-  "test md with json" >> {
-    ParserRun.parse(NWChemParser, "parsers/nwchem/test/examples/md/output.out", "json") must_== ParseResult.ParseSuccess
-  }
-}
-- 
GitLab