mirror of
https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local
synced 2024-11-01 03:33:46 +01:00
Add support of list_basis_available for a set of element
This commit is contained in:
parent
8aa5904ada
commit
4cc365d22f
@ -4,7 +4,7 @@
|
|||||||
"""EMSL Api.
|
"""EMSL Api.
|
||||||
|
|
||||||
Usage:
|
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_list_elements <db_path> <basis_name>
|
||||||
EMSL_api.py get_basis_data <db_path> <basis_name> <elts>...
|
EMSL_api.py get_basis_data <db_path> <basis_name> <elts>...
|
||||||
EMSL_api.py get_list_formats
|
EMSL_api.py get_list_formats
|
||||||
@ -42,8 +42,10 @@ if __name__ == '__main__':
|
|||||||
if arguments["get_list_basis"]:
|
if arguments["get_list_basis"]:
|
||||||
db_path = arguments["<db_path>"]
|
db_path = arguments["<db_path>"]
|
||||||
|
|
||||||
|
elts = arguments["<elts>"]
|
||||||
|
|
||||||
e = EMSL_local(db_path=db_path)
|
e = EMSL_local(db_path=db_path)
|
||||||
l = e.get_list_basis_available()
|
l = e.get_list_basis_available(elts)
|
||||||
for i in l:
|
for i in l:
|
||||||
print i
|
print i
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -48,7 +48,7 @@ function _mycomplete_()
|
|||||||
fi
|
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"])
|
""" % " ".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:
|
with open(path + "/EMSL_api.rc", "w") as f:
|
||||||
|
@ -202,14 +202,23 @@ class EMSL_local:
|
|||||||
def __init__(self, db_path=None):
|
def __init__(self, db_path=None):
|
||||||
self.db_path = db_path
|
self.db_path = db_path
|
||||||
|
|
||||||
def get_list_basis_available(self):
|
def get_list_basis_available(self, elts=[]):
|
||||||
|
|
||||||
conn = sqlite3.connect(self.db_path)
|
conn = sqlite3.connect(self.db_path)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
||||||
|
if not elts:
|
||||||
|
|
||||||
c.execute("SELECT DISTINCT name from all_value")
|
c.execute("SELECT DISTINCT name from all_value")
|
||||||
data = c.fetchall()
|
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]
|
data = [i[0] for i in data]
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user