def default_peek(python_type, exposes):
with_args = False<EOL>make = python_type<EOL>try:<EOL><INDENT>make()<EOL><DEDENT>except (SystemExit, KeyboardInterrupt):<EOL><INDENT>raise<EOL><DEDENT>except:<EOL><INDENT>make = lambda: python_type.__new__(python_type)<EOL>try:<EOL><INDENT>make()<EOL><DEDENT>except (SystemExit, KeyboardInterrupt):<EOL><INDENT>raise<EOL><DEDENT>except:<EOL><INDENT>make = lambda args: python_type.__new__(python_type, *args)<EOL>with_args = True<EOL><DEDENT><DEDENT>def missing(attr):<EOL><INDENT>return AttributeError("<STR_LIT>".format(attr, python_type))<EOL><DEDENT>if with_args:<EOL><INDENT>def peek(store, container, _stack=None):<EOL><INDENT>state = []<EOL>for attr in exposes: <EOL><INDENT>if attr in container:<EOL><INDENT>state.append(store.peek(attr, container, _stack=_stack))<EOL><DEDENT>else:<EOL><INDENT>state.append(None)<EOL><DEDENT><DEDENT>return make(state)<EOL><DEDENT><DEDENT>elif '<STR_LIT>' in exposes:<EOL><INDENT>def peek(store, container, _stack=None):<EOL><INDENT>obj = make()<EOL>for attr in container:<EOL><INDENT>val = store.peek(attr, container, _stack=_stack)<EOL>try:<EOL><INDENT>setattr(obj, attr, val)<EOL><DEDENT>except AttributeError:<EOL><INDENT>raise missing(attr)<EOL><DEDENT><DEDENT>return obj<EOL><DEDENT><DEDENT>else:<EOL><INDENT>def peek(store, container, _stack=None):<EOL><INDENT>obj = make()<EOL>for attr in exposes: <EOL><INDENT>if attr in container:<EOL><INDENT>val = store.peek(attr, container, _stack=_stack)<EOL><DEDENT>else:<EOL><INDENT>val = None<EOL><DEDENT>try:<EOL><INDENT>setattr(obj, attr, val)<EOL><DEDENT>except AttributeError:<EOL><INDENT>raise missing(attr)<EOL><DEDENT><DEDENT>return obj<EOL><DEDENT><DEDENT>return peek<EOL>
Autoserializer factory.

Works best in Python 3.

Arguments:

    python_type (type): type constructor.

    exposes (iterable): sequence of attributes.

Returns:

    callable: deserializer (`peek` routine).