mirror of
https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local
synced 2024-12-22 20:34:23 +01:00
Add new without --with_L
This commit is contained in:
parent
a14d7ffba9
commit
45e0dfb854
@ -11,6 +11,7 @@ Usage:
|
||||
EMSL_api.py get_basis_data --basis=basis_name
|
||||
[--atom=atom_name...]
|
||||
[--db_path=db_path]
|
||||
[--with_l]
|
||||
[(--save [--path=path])]
|
||||
EMSL_api.py get_list_formats
|
||||
EMSL_api.py create_db --db_path=db_path
|
||||
@ -91,7 +92,8 @@ if __name__ == '__main__':
|
||||
basis_name = arguments["--basis"]
|
||||
elts = arguments["--atom"]
|
||||
|
||||
l = e.get_basis(basis_name, elts)
|
||||
print arguments["--with_l"]
|
||||
l = e.get_basis(basis_name, elts,arguments["--with_l"])
|
||||
str_ = "\n\n".join(l) + "\n"
|
||||
|
||||
if arguments["--save"]:
|
||||
|
@ -233,6 +233,7 @@ class EMSL_local:
|
||||
data = [i[:] for i in data]
|
||||
|
||||
conn.close()
|
||||
|
||||
return data
|
||||
|
||||
def get_list_element_available(self, basis_name):
|
||||
@ -251,13 +252,32 @@ class EMSL_local:
|
||||
conn.close()
|
||||
return data
|
||||
|
||||
def get_basis(self, basis_name, elts):
|
||||
def get_basis(self, basis_name, elts=None, with_l=False):
|
||||
|
||||
def get_list_type(l_line):
|
||||
l = []
|
||||
for i, line in enumerate(l_line):
|
||||
|
||||
m = re.search(p, line)
|
||||
if m:
|
||||
l.append([m.group(1), i])
|
||||
try:
|
||||
l[-2].append(i)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
l[-1].append(i + 1)
|
||||
return l
|
||||
|
||||
import re
|
||||
|
||||
# __ _
|
||||
# /__ _ _|_ _|_ ._ _ ._ _ _ _. |
|
||||
# \_| (/_ |_ | | (_) | | | _> (_| |
|
||||
# |
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
c = conn.cursor()
|
||||
|
||||
d = []
|
||||
|
||||
if elts:
|
||||
cmd_ele = "AND " + " ".join(cond_sql_or("elt", elts))
|
||||
else:
|
||||
@ -268,11 +288,42 @@ class EMSL_local:
|
||||
{cmd_ele}'''.format(basis_name=basis_name,
|
||||
cmd_ele=cmd_ele))
|
||||
|
||||
for data in c.fetchall():
|
||||
d.append(data[0].strip())
|
||||
|
||||
l_data_raw = c.fetchall()
|
||||
conn.close()
|
||||
return d
|
||||
|
||||
# |_| _. ._ _| | _ || | ||
|
||||
# | | (_| | | (_| | (/_ |_
|
||||
#
|
||||
|
||||
p = re.compile(ur'^(\w)\s+\d+\b')
|
||||
|
||||
l_data = []
|
||||
|
||||
for data_raw in l_data_raw:
|
||||
|
||||
basis = data_raw[0].strip()
|
||||
|
||||
l_line_raw = basis.split("\n")
|
||||
|
||||
l_line = [l_line_raw[0]]
|
||||
|
||||
for type_, begin, end in get_list_type(l_line_raw):
|
||||
|
||||
if not(with_l) and type_ in "L":
|
||||
body = l_line_raw[begin + 1:end]
|
||||
|
||||
l_line += [l_line_raw[begin].replace("L", "S")]
|
||||
l_line += body
|
||||
|
||||
l_line += [l_line_raw[begin].replace("L", "P")]
|
||||
l_line += body
|
||||
else:
|
||||
l_line += l_line_raw[begin:end]
|
||||
|
||||
l_data.append("\n".join(l_line))
|
||||
|
||||
return l_data
|
||||
|
||||
|
||||
format_dict = \
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user