Skip to content

Commit

Permalink
Merge pull request #10 from dvp2015/fix-open-encoding
Browse files Browse the repository at this point in the history
fix: #9 use encoding cp1251 to open MCNP files and #8 'is' instead of 'equal'

Merged first into a respective branch, to pass through CI
  • Loading branch information
travleev authored Nov 15, 2021
2 parents 1e5a0b0 + 7c49cef commit 2a1d275
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Python setup folders
build/
*.egg-info
.eggs/
numjuggler/version.py

# Byte-compiled
Expand Down
8 changes: 4 additions & 4 deletions numjuggler/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ def _split_cell(input_, self):
# warn if there is possibility for an array following the fill
# keyword:
# TODO fill value can be an array
if 'fill' is s.lower() and 'lat' in ''.join(parm).lower():
if 'fill' == s.lower() and 'lat' in ''.join(parm).lower():
print('WARNING: fill keyword followed by an array', end=' ')
print('cannot be parsed')

Expand Down Expand Up @@ -1176,7 +1176,7 @@ def get_cards(inp, debug=None, preservetabs=False):
if it < dt and debug is None:
# print('Reading from dump')
# dump is youger
dfile = open(dname, 'r')
dfile = open(dname, 'r', encoding="cp1251")
cl = cPickle.load(dfile)
for c in cl:
yield c
Expand All @@ -1189,7 +1189,7 @@ def get_cards(inp, debug=None, preservetabs=False):
if debug is None:
# otherwise the instances of c contain the file object, which
# cannot be dumped.
dfile = open(dname, 'w')
dfile = open(dname, 'w', encoding="cp1251")
cPickle.dump(cl, dfile)
else:
def get_cards(inp, debug=None, preservetabs=False):
Expand Down Expand Up @@ -1242,7 +1242,7 @@ def replace_tab(l, cln, preserve=False, ts=8):
return l[:]

cln = 0 # current line number. Used only for debug
with open(inp, 'r') as f:
with open(inp, 'r', encoding="cp1251") as f:
# define the first block:
# -----------------------

Expand Down

0 comments on commit 2a1d275

Please sign in to comment.