-
Notifications
You must be signed in to change notification settings - Fork 29
Support READ cards #30
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
Conversation
| _READ_RE = re.compile(r""" | ||
| \s*read # Keyword | ||
| \s.*?file # Everything up to filename | ||
| \s*=\s* # = sign (required) with optional spaces | ||
| (\S+) # The file name is anything without whitespace | ||
| .* # Anything else until end-of-line | ||
| """, re.IGNORECASE | re.VERBOSE | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not going to be perfectly robust in that it may be overly generous with what counts as a read, but I think it's probably robust enough.
paulromano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tjlaboss Thanks for this addition! I've started to add proper tests on this repo so it would be prudent to have a test for this as well. Can you put together a test?
|
@tjlaboss want any help with tests? |
|
Added tests. I included a new tests/inputs/ directory. It necessarily breaks from the convention of the other tests including the MCNP decks as strings because the target of |
MicahGale
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
What's your patch coverage though?
|
@paulromano, are these tests acceptable? |
paulromano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made two small updates: 1) use pathlib over os.path, and 2) make the regex multiline and add ^, which makes it about 4× faster in my testing. Good to go now!
Closes #29
Where a
READcard is found, recursively insert the contents of the targetFILE=.... Other keywords (ECHO,NOECHO,ENCODE=..., andDECODE=...) are ignored.Example:
testRead.imcnp:
testReadTarget.imcnp:
testReadRecursive.imcnp:
This becomes:
And thereby: