Skip to content

Commit 2ec2801

Browse files
committed
fix illegals logic
1 parent cd86b97 commit 2ec2801

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

pyinfraformat/core/core.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,6 @@ def add_survey(self, survey):
612612
"""Add survey information to object."""
613613
self.survey.add(survey)
614614

615-
def _add_illegal(self, illegal):
616-
"""Add illegal lines to object."""
617-
self._illegal.add(illegal)
618-
619615
def plot(self, output="figure", figsize=(4, 4)):
620616
"""
621617
Plot a diagram of a sounding with matplotlib.
@@ -660,17 +656,13 @@ def get_comments_list(self):
660656
"""Get fileheader as a dict."""
661657
return self.inline_comment.data
662658

663-
def get_illegals_list(self):
664-
"""Get fileheader as a dict."""
665-
return self._illegal.data
666-
667659
def get_dict(self):
668660
"""Get survey data, hole header, fileheader, comments and illegals as list of dicts."""
669661
d_header = self.get_header_dict()
670662
data_list = self.get_data_list()
671663
d_fileheader = self.get_fileheader_dict()
672664
comment_list = self.get_comments_list()
673-
illegals_list = self.get_illegals_list()
665+
illegals_list = self.illegals
674666
return {
675667
"header": d_header,
676668
"fileheader": d_fileheader,

pyinfraformat/core/io.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,11 @@ def write_body(hole, f, comments=True, illegal=False, body_spacer=None, body_spa
457457

458458
# Gather illegal lines
459459
if illegal:
460-
for linenumber, line_string in hole._illegal.data:
460+
illegals_dict = {
461+
item["linenumber"]: item["line_highlighted"] + " # " + item["error"]
462+
for item in hole.illegals
463+
}
464+
for linenumber, line_string in illegals_dict.items():
461465
if int(linenumber) not in body_text:
462466
body_text[int(line_dict["linenumber"])] = line_string
463467
else:

0 commit comments

Comments
 (0)