mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Using context manager. Improving docstring
This commit is contained in:
parent
1cdd7084fc
commit
87bde4d72c
1 changed files with 21 additions and 20 deletions
|
|
@ -419,38 +419,39 @@ def __wwinp_reader(path):
|
|||
path : str or pathlib.Path
|
||||
Location of the wwinp file
|
||||
"""
|
||||
fh = open(path, 'r')
|
||||
|
||||
# read the first line of the file and
|
||||
# keep only the first four entries
|
||||
while(True):
|
||||
line = next(fh)
|
||||
if line and not line.startswith('c'):
|
||||
break
|
||||
with open(path, 'r') as fh:
|
||||
|
||||
values = line.strip().split()[:4]
|
||||
for value in values:
|
||||
yield value
|
||||
# read the first line of the file and
|
||||
# keep only the first four entries
|
||||
while True:
|
||||
line = next(fh)
|
||||
if line and not line.startswith('c'):
|
||||
break
|
||||
|
||||
# the remainder of the file can be read as
|
||||
# sequential values
|
||||
while(True):
|
||||
line = next(fh)
|
||||
# skip empty or commented lines
|
||||
if not line or line.startswith('c'):
|
||||
continue
|
||||
values = line.strip().split()
|
||||
values = line.strip().split()[:4]
|
||||
for value in values:
|
||||
yield value
|
||||
|
||||
# the remainder of the file can be read as
|
||||
# sequential values
|
||||
while True:
|
||||
line = next(fh)
|
||||
# skip empty or commented lines
|
||||
if not line or line.startswith('c'):
|
||||
continue
|
||||
values = line.strip().split()
|
||||
for value in values:
|
||||
yield value
|
||||
|
||||
|
||||
def wwinp_to_wws(path):
|
||||
"""Creates WeightWindows classes from a wwinp file
|
||||
|
||||
Parameters
|
||||
----------
|
||||
path : str
|
||||
Path to the wwinp file.
|
||||
path : str or pathlib.Path object
|
||||
Path to the wwinp file
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue