Skip to content

Commit d7cc23e

Browse files
committed
RF: Store name of XML file being parsed so it is available to parsing logic
1 parent 5cbc26a commit d7cc23e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

nibabel/xmlutils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(self, encoding='utf-8', buffer_size=35000000, verbose=0):
6565
self.encoding = encoding
6666
self.buffer_size = buffer_size
6767
self.verbose = verbose
68+
self.fname = None # set on calls to parse
6869

6970
def _create_parser(self):
7071
"""Internal function that allows subclasses to mess
@@ -97,6 +98,8 @@ def parse(self, string=None, fname=None, fptr=None):
9798
elif fname is not None:
9899
fptr = open(fname, 'r')
99100

101+
# store the name of the xml file in case it is needed during parsing
102+
self.fname = getattr(fptr, 'name', None)
100103
parser = self._create_parser()
101104
for name in self.HANDLER_NAMES:
102105
setattr(parser, name, getattr(self, name))

0 commit comments

Comments
 (0)