<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _enumerator(opener, entry_cls, format_code=None, filter_code=None):
 """Return an archive enumerator from a user-defined source, using a user- defined entry type. """


    archive_res = _archive_read_new()

    try:
        r = _set_read_context(archive_res, format_code, filter_code)
        opener(archive_res)

        def it():
            while 1:
                with _archive_read_next_header(archive_res) as entry_res:
                    if entry_res is None:
                        break

                    e = entry_cls(archive_res, entry_res)
                    yield e
                    if e.is_consumed is False:
                        _archive_read_data_skip(archive_res)
        yield it()
    finally:
        _archive_read_free(archive_res)