Skip to content

Commit

Permalink
update error for cp2k aimdoutput if none pattern is matched
Browse files Browse the repository at this point in the history
  • Loading branch information
robinzyb committed Oct 30, 2023
1 parent a1a171a commit 1a4b985
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dpdata/cp2k/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __next__(self):
def get_log_block_generator(self):
lines = []
delimiter_flag = False
yield_flag = False
while True:
line = self.log_file_object.readline()
if line:
Expand All @@ -91,15 +92,20 @@ def get_log_block_generator(self):
if any(p.match(line) for p in avail_patterns):
delimiter_flag = True
else:
if not yield_flag:
raise StopIteration("None of the delimiter patterns are matched")
break
if delimiter_flag is True:
raise RuntimeError("This file lacks some content, please check")

def get_xyz_block_generator(self):
p3 = re.compile(r"^\s*(\d+)\s*")
yield_flag = False
while True:
line = self.xyz_file_object.readline()
if not line:
if not yield_flag:
raise StopIteration("None of the xyz patterns are matched")
break
if p3.match(line):
atom_num = int(p3.match(line).group(1))
Expand Down

0 comments on commit 1a4b985

Please sign in to comment.