switched reraise_visit to be just a kwarg

This commit is contained in:
Mahmoud Hashemi 2015-09-21 03:04:33 -07:00
parent 0d6486c402
commit 27a4bc1b6d
1 changed files with 4 additions and 2 deletions

View File

@ -639,7 +639,7 @@ def default_exit(path, key, old_parent, new_parent, new_items):
def remap(root, visit=default_visit, enter=default_enter, exit=default_exit, def remap(root, visit=default_visit, enter=default_enter, exit=default_exit,
reraise_visit=True): **kwargs):
"""The remap ("recursive map") function is used to traverse and """The remap ("recursive map") function is used to traverse and
transform nested structures. Lists, tuples, sets, and dictionaries transform nested structures. Lists, tuples, sets, and dictionaries
are just a few of the data structures commonly nested into are just a few of the data structures commonly nested into
@ -726,13 +726,15 @@ def remap(root, visit=default_visit, enter=default_enter, exit=default_exit,
""" """
# TODO: enter() return (False, items) to continue traverse but cancel copy? # TODO: enter() return (False, items) to continue traverse but cancel copy?
# TODO: reraise_visit to kwarg only
if not callable(visit): if not callable(visit):
raise TypeError('visit expected callable, not: %r' % visit) raise TypeError('visit expected callable, not: %r' % visit)
if not callable(enter): if not callable(enter):
raise TypeError('enter expected callable, not: %r' % enter) raise TypeError('enter expected callable, not: %r' % enter)
if not callable(exit): if not callable(exit):
raise TypeError('exit expected callable, not: %r' % exit) raise TypeError('exit expected callable, not: %r' % exit)
reraise_visit = kwargs.pop('reraise_visit', True)
if kwargs:
raise TypeError('unexpected keyword arguments: %r' % kwargs.keys())
path, registry, stack = (), {}, [(None, root)] path, registry, stack = (), {}, [(None, root)]
new_items_stack = [] new_items_stack = []