Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing parser error with read card #372

Merged
merged 17 commits into from
Apr 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moved is_comment to a global namespace
MicahGale committed Feb 15, 2024
commit a006a6f0d422a6c5d936430b77e212652aa8f963
15 changes: 1 addition & 14 deletions montepy/input_parser/input_syntax_reader.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
from montepy.input_parser.input_file import MCNP_InputFile
from montepy.input_parser.mcnp_input import Input, Message, ReadInput, Title
from montepy.input_parser.read_parser import ReadParser
from montepy.utilities import is_comment
import os
import warnings

@@ -88,20 +89,6 @@ def read_front_matters(fh, mcnp_version):
break


def is_comment(line):
""""""
upper_start = line[0 : BLANK_SPACE_CONTINUE + 1].upper()
non_blank_comment = upper_start and line.lstrip().upper().startswith("C ")
if non_blank_comment:
return True
blank_comment = (
"C\n" == upper_start.lstrip()
or "C\r\n" == upper_start.lstrip()
or ("C" == upper_start and "\n" not in line)
)
return blank_comment or non_blank_comment


def read_data(fh, mcnp_version, block_type=None, recursion=False):
"""
Reads the bulk of an MCNP file for all of the MCNP data.
22 changes: 22 additions & 0 deletions montepy/utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2024, Battelle Energy Alliance, LLC All Rights Reserved.
from montepy.constants import BLANK_SPACE_CONTINUE
import functools
import re

@@ -31,6 +32,27 @@ def fortran_float(number_string):
raise ValueError(f"Value Not parsable as float: {number_string}") from e


def is_comment(line):
"""
Determines if the line is a `C ` style comment.

:param line: the line to analyze
:type line: str
:returns: True if the line is a comment
:rtype: bool
"""
upper_start = line[0 : BLANK_SPACE_CONTINUE + 1].upper()
non_blank_comment = upper_start and line.lstrip().upper().startswith("C ")
if non_blank_comment:
return True
blank_comment = (
"C\n" == upper_start.lstrip()
or "C\r\n" == upper_start.lstrip()
or ("C" == upper_start and "\n" not in line)
)
return blank_comment or non_blank_comment


def make_prop_val_node(
hidden_param, types=None, base_type=None, validator=None, deletable=False
):