Commit 378d392b authored by Niccolo.Ricardi's avatar Niccolo.Ricardi
Browse files

minor changes to get_nbas

parent 109b23d8
......@@ -276,30 +276,27 @@ def get_nbas(filepath, with_ccp=False, json_file="", log_file="", index=[2,3,4])
json_file=os.path.join(dir_, json_file)
else:
json_files = gl.glob(os.path.join(dir_,"*.json"))
if len(json_files) == 1:
json_file=json_files[0]
else:
kwargs = dict(to_console=False, to_file=True, to_json=True)
if json_file:
kwargs.update(dict(json_file=json_file))
if log_file:
kwargs.update(dict(log_file=log_file))
out = ccp.Parser(filepath, **kwargs)
try:
json_file = [i for i in gl.glob(os.path.join(dir_,"*.json")) if i not in json_files][0]
assert json_file == default_ccpjson
except IndexError:
ccjlog.critical("The json file was already there. Will use default name: {}".format(default_ccpjson))
except AssertionError:
ccjlog.critical("CCParser's default seems to be \"{}\" change default_ccpjson in this function!!".format(json_file))
default_ccpjson = json_file
kwargs = dict(to_console=False, to_file=True, to_json=True)
if json_file:
kwargs.update(dict(json_file=json_file))
if log_file:
kwargs.update(dict(log_file=log_file))
out = ccp.Parser(filepath, **kwargs)
try:
json_file = [i for i in gl.glob(os.path.join(dir_,"*.json")) if i not in json_files][0]
assert json_file == default_ccpjson
except IndexError:
ccjlog.critical("The json file was already there. Will use default name: {}".format(default_ccpjson))
except AssertionError:
ccjlog.critical("CCParser's default seems to be \"{}\" change default_ccpjson in this function!!".format(json_file))
default_ccpjson = json_file
parsed = ut.load_js(json_file)
nbas["nbasAB"] = parsed["nbas"][index[0]][0]
nbas["nbasA"] = parsed["nbas"][index[1]][0]
nbas["nbasB"] = parsed["nbas"][index[2]][0]
else:
with open(file) as f:
with open(filepath) as f:
r = f.read()
pattern = r"There are (?P<shells>\d+) shells and (?P<bsf>\d+) basis functions"
parsed = re.findall(pattern, r)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment