10
0
mirror of https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local synced 2024-12-22 04:13:43 +01:00
This commit is contained in:
Thomas Applencourt 2015-03-17 18:03:03 +01:00
parent 6d84205ef2
commit cfb4759273
2 changed files with 40 additions and 21 deletions

View File

@ -5,7 +5,6 @@ import time
import sqlite3 import sqlite3
from collections import OrderedDict from collections import OrderedDict
from src.parser_handler import format_dict
def install_with_pip(name): def install_with_pip(name):
@ -40,21 +39,11 @@ class EMSL_dump:
def __init__(self, db_path=None, format="GAMESS-US", contraction="True"): def __init__(self, db_path=None, format="GAMESS-US", contraction="True"):
if format not in format_dict: from src.parser_handler import get_parser_function
print >> sys.stderr, "Format {0} doesn't exist. Choose in:".format( from src.parser_handler import check_format
format)
print >> sys.stderr, format_dict.keys()
sys.exit(1)
else:
self.format = format
if format_dict[self.format]: self.format = check_format(format)
self.parser = format_dict[self.format] self.parser = get_parser_function(self.format)
else:
print >> sys.stderr, "We have no parser for this format"
print >> sys.stderr, "Fill free to Fock /pull request"
print >> sys.stderr, "You just need to add a function like"
print >> sys.stderr, "'parse_basis_data_gamess_us' to parse you'r format"
if db_path: if db_path:
self.db_path = db_path self.db_path = db_path
@ -75,7 +64,8 @@ class EMSL_dump:
def get_list_format(self): def get_list_format(self):
"""List all the format available in EMSL""" """List all the format available in EMSL"""
return format_dict from src.parser_handler import parser_dict
return parser_dict.keys()
def set_db_path(self, path): def set_db_path(self, path):
"""Define the database path""" """Define the database path"""

View File

@ -29,8 +29,9 @@ from src.parser.gaussian94 import parse_basis_data_gaussian94
from src.parser.nwchem import parse_basis_data_nwchem from src.parser.nwchem import parse_basis_data_nwchem
format_dict = {"Gaussian94": parse_basis_data_gaussian94, parser_dict = {"Gaussian94": parse_basis_data_gaussian94,
"GAMESS-US": parse_basis_data_gamess_us, "GAMESS-US": parse_basis_data_gamess_us,
"NWChem": parse_basis_data_nwchem,
"GAMESS-UK": None, "GAMESS-UK": None,
"Turbomole": None, "Turbomole": None,
"TX93": None, "TX93": None,
@ -43,8 +44,34 @@ format_dict = {"Gaussian94": parse_basis_data_gaussian94,
"Dalton": None, "Dalton": None,
"deMon-KS": None, "deMon-KS": None,
"deMon2k": None, "deMon2k": None,
"AcesII": None, "AcesII": None}
"NWChem": parse_basis_data_nwchem}
def check_format(format):
try:
parser_dict[format]
except KeyError:
str_ = ["This format ({0}) is not available in EMSL".format(format),
"EMSL provide this list : {0}".format(parser_dict.keys())]
print >> sys.stderr, "\n".join(str_)
sys.exit(1)
else:
return format
def get_parser_function(format):
if not parser_dict[format]:
list_parser = [k for k, v in parser_dict.iteritems() if v]
str_ = ["We have no parser for this format {0}".format(format),
"We only support {0}".format(list_parser),
"Fill free to Fock /pull request",
"You just need to add a function like this one:",
"'src.pars.gamess_us.parse_basis_data_gamess_us'"]
print >> sys.stderr, "\n".join(str_)
sys.exit(1)
else:
return parser_dict[format]
# _____ _ _ _ _ # _____ _ _ _ _
# / ___| | | | (_) | | # / ___| | | | (_) | |
@ -78,7 +105,8 @@ def get_symmetry_function(format):
print >> sys.stderr, "You need to add a function in symmetry_dict" print >> sys.stderr, "You need to add a function in symmetry_dict"
print >> sys.stderr, "for your format ({0})".format(format) print >> sys.stderr, "for your format ({0})".format(format)
sys.exit(1) sys.exit(1)
return f else:
return f
# _ _ _ _ _ _ _ _ _ ______ _ _ # _ _ _ _ _ _ _ _ _ ______ _ _
# | | | | | | | ( | ) | ( | ) | _ (_) | | # | | | | | | | ( | ) | ( | ) | _ (_) | |
@ -106,4 +134,5 @@ def get_handle_l_function(format):
print >> sys.stderr, "You need to add a function in handle_l_dict" print >> sys.stderr, "You need to add a function in handle_l_dict"
print >> sys.stderr, "for your format ({0})".format(format) print >> sys.stderr, "for your format ({0})".format(format)
sys.exit(1) sys.exit(1)
return f else:
return f