mirror of
https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local
synced 2024-10-31 19:23:42 +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.
|
||||
|
||||
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
|
||||
|
||||
|
2
setup.py
2
setup.py
@ -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:
|
||||
|
@ -202,14 +202,23 @@ 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()
|
||||
|
||||
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]
|
||||
|
||||
conn.close()
|
||||
|
Loading…
Reference in New Issue
Block a user