10
0
mirror of https://github.com/LCPQ/EMSL_Basis_Set_Exchange_Local synced 2024-10-31 19:23:42 +01:00
This commit is contained in:
Thomas Applencourt 2015-03-11 10:37:15 +01:00
parent 532621736c
commit 0267d41e4f
3 changed files with 28 additions and 18 deletions

View File

@ -29,6 +29,7 @@ def install_with_pip(name):
class EMSL_dump:
"""
This call implement all you need for download the EMSL and save it localy
"""
@ -260,7 +261,6 @@ class EMSL_dump:
else:
q_in.task_done()
def enqueue():
for [name, path_xml, des, elts] in list_basis_array:
q_in.put([name, path_xml, des, elts])

View File

@ -91,6 +91,7 @@ def string_to_nb_mo(str_l):
class EMSL_local:
"""
All the method for using the EMSL db localy
"""
@ -113,13 +114,13 @@ class EMSL_local:
l = []
for i, line in enumerate(atom_basis):
m = re.search(self.p, line)
if m:
l.append([m.group(1), i])
try:
l[-2].append(i)
except IndexError:
pass
m = re.search(self.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
@ -305,7 +306,8 @@ class EMSL_local:
tail_s = common + "{:>23.7f}".format(float(a[2]))
body_s.append(tail_s)
# Is only a whan only 3 elements, coef for p == coef for s
# Is only a whan only 3 elements, coef for p == coef
# for s
try:
tail_p = common + "{:>23.7f}".format(float(a[3]))
except IndexError:

View File

@ -59,12 +59,20 @@ class Pattern(object):
either = [list(child.children) for child in transform(self).children]
for case in either:
for e in [child for child in case if case.count(child) > 1]:
if type(e) is Argument or type(e) is Option and e.argcount:
if isinstance(
e,
Argument) or isinstance(
e,
Option) and e.argcount:
if e.value is None:
e.value = []
elif type(e.value) is not list:
elif not isinstance(e.value, list):
e.value = e.value.split()
if type(e) is Command or type(e) is Option and e.argcount == 0:
if isinstance(
e,
Command) or isinstance(
e,
Option) and e.argcount == 0:
e.value = 0
return self
@ -84,10 +92,10 @@ def transform(pattern):
if any(t in map(type, children) for t in parents):
child = [c for c in children if type(c) in parents][0]
children.remove(child)
if type(child) is Either:
if isinstance(child, Either):
for c in child.children:
groups.append([c] + children)
elif type(child) is OneOrMore:
elif isinstance(child, OneOrMore):
groups.append(child.children * 2 + children)
else:
groups.append(child.children + children)
@ -117,10 +125,10 @@ class LeafPattern(Pattern):
left_ = left[:pos] + left[pos + 1:]
same_name = [a for a in collected if a.name == self.name]
if type(self.value) in (int, list):
if type(self.value) is int:
if isinstance(self.value, int):
increment = 1
else:
increment = ([match.value] if type(match.value) is str
increment = ([match.value] if isinstance(match.value, str)
else match.value)
if not same_name:
match.value = increment
@ -151,7 +159,7 @@ class Argument(LeafPattern):
def single_match(self, left):
for n, pattern in enumerate(left):
if type(pattern) is Argument:
if isinstance(pattern, Argument):
return n, Argument(self.name, pattern.value)
return None, None
@ -169,7 +177,7 @@ class Command(Argument):
def single_match(self, left):
for n, pattern in enumerate(left):
if type(pattern) is Argument:
if isinstance(pattern, Argument):
if pattern.value == self.name:
return n, Command(self.name, True)
else: