From a8c430d669de23aac6f9a11a211615a2ca3ffbe6 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 12 Mar 2015 14:04:42 +0100 Subject: [PATCH] Add --check for checking the output --- EMSL_api.py | 6 ++++-- src/EMSL_local.py | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/EMSL_api.py b/EMSL_api.py index 38d8f07..0fa5e23 100755 --- a/EMSL_api.py +++ b/EMSL_api.py @@ -14,6 +14,7 @@ Usage: [--atom=...] [--db_path=] [(--save [--path=])] + [--check=] EMSL_api.py list_formats EMSL_api.py create_db --db_path= --format= @@ -115,8 +116,9 @@ if __name__ == '__main__': basis_name = arguments["--basis"][0] elts = arguments["--atom"] - l = e.get_basis(basis_name, elts) - str_ = "\n\n".join(l) + "\n" + l_atom_basis = e.get_basis(basis_name, elts, arguments["--check"]) + # Add separation between atoms, and a empty last line + str_ = "\n\n".join(l_atom_basis) + "\n" if arguments["--save"]: diff --git a/src/EMSL_local.py b/src/EMSL_local.py index f427c71..4cb41f9 100755 --- a/src/EMSL_local.py +++ b/src/EMSL_local.py @@ -298,7 +298,7 @@ class EMSL_local: return [str(i[0]) for i in c.fetchall()] - def get_basis(self, basis_name, elts=None, checking=None): + def get_basis(self, basis_name, elts=None, check_format=None): """ Return the data from the basis set """ @@ -329,12 +329,20 @@ class EMSL_local: # C h e c k # # ~#~#~#~#~ # - checking = False + d_check = {"gamess": check_gamess, + "NWChem": check_NWChem} + + if check_format: + try: + f = d_check[check_format] + except KeyError: + str_ = """This format is not handle. Chose one of : {}""" + print >>sys.stderr, str_.format(format(str(d_check.keys()))) + sys.exit(1) - if checking: for atom_basis in l_atom_basis: for type_, _, _ in self.get_list_type(atom_basis.split("\n")): - check_gamess(type_) + f(type_) # ~#~#~#~#~#~ # # R e t u r n #