10
0
mirror of https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local synced 2024-12-22 20:34:23 +01:00

Add support of list_basis_available for a set of element

This commit is contained in:
Thomas Applencourt 2014-11-20 15:33:26 +01:00
parent 8aa5904ada
commit 4cc365d22f
3 changed files with 17 additions and 6 deletions

View File

@ -4,7 +4,7 @@
"""EMSL Api.
Usage:
EMSL_api.py get_list_basis <db_path>
EMSL_api.py get_list_basis <db_path> [<elts>...]
EMSL_api.py get_list_elements <db_path> <basis_name>
EMSL_api.py get_basis_data <db_path> <basis_name> <elts>...
EMSL_api.py get_list_formats
@ -42,8 +42,10 @@ if __name__ == '__main__':
if arguments["get_list_basis"]:
db_path = arguments["<db_path>"]
elts = arguments["<elts>"]
e = EMSL_local(db_path=db_path)
l = e.get_list_basis_available()
l = e.get_list_basis_available(elts)
for i in l:
print i

View File

@ -48,7 +48,7 @@ function _mycomplete_()
fi
}
complete -o default -F _mycomplete_ EMSL_api.py
complete -o default -F _mycomplete_ ./EMSL_api.py
""" % " ".join(["get_list_basis", "get_list_elements", "get_basis_data", "get_list_formats", "create_db", "-h", "--help", "--version"])
with open(path + "/EMSL_api.rc", "w") as f:

View File

@ -202,13 +202,22 @@ class EMSL_local:
def __init__(self, db_path=None):
self.db_path = db_path
def get_list_basis_available(self):
def get_list_basis_available(self, elts=[]):
conn = sqlite3.connect(self.db_path)
c = conn.cursor()
c.execute("SELECT DISTINCT name from all_value")
data = c.fetchall()
if not elts:
c.execute("SELECT DISTINCT name from all_value")
data = c.fetchall()
else:
cmd = ["SELECT name FROM all_value WHERE elt=?"] * len(elts)
cmd = " INTERSECT ".join(cmd) + ";"
c.execute(cmd, elts)
data = c.fetchall()
data = [i[0] for i in data]