Exemplo n.º 1
0
def parse(events):
    """Like ijson.parse, but takes events generated via ijson.basic_parse instead
    of a file"""
    warnings.warn(_common_functions_warn, DeprecationWarning)
    return utils.coros2gen(events,
        (parse_basecoro, (), {})
    )
Exemplo n.º 2
0
def items(events, prefix, map_type=None):
    """Like ijson.items, but takes events generated via ijson.parse instead of
    a file"""
    warnings.warn(_common_functions_warn, DeprecationWarning)
    return utils.coros2gen(events,
        (items_basecoro, (prefix,), {'map_type': map_type})
    )
Exemplo n.º 3
0
 def kvitems_gen(file_obj,
                 prefix,
                 map_type=None,
                 buf_size=64 * 1024,
                 **config):
     return utils.coros2gen(
         file_source(file_obj, buf_size=buf_size),
         *_kvitems_pipeline(backend, prefix, map_type, config))
Exemplo n.º 4
0
def items(events, prefix, map_type=None, skip_key=None):
    """
    This is copied from ``ijson/common.py``. A ``skip_key`` argument is added, which is passed as a keyword argument to
    :meth:`~kingfisher_scrapy.util.items_basecoro`. Otherwise, the method is identical.
    """
    return utils.coros2gen(events,
        (items_basecoro, (prefix,), {'map_type': map_type, 'skip_key': skip_key})  # noqa: E128
    )
Exemplo n.º 5
0
 def parse(source, buf_size=64 * 1024, **config):
     source = _get_source(source)
     if is_async_file(source):
         return backend['parse_async'](source, buf_size=buf_size, **config)
     elif is_file(source):
         return backend['parse_gen'](source, buf_size=buf_size, **config)
     elif is_iterable(source):
         return utils.coros2gen(source, (parse_basecoro, (), {}))
     raise ValueError("Unknown source type: %r" % type(source))
Exemplo n.º 6
0
 def kvitems(source, prefix, map_type=None, buf_size=64*1024, **config):
     source = _get_source(source)
     if is_async_file(source):
         return backend['kvitems_async'](
             source, prefix, map_type=map_type, buf_size=buf_size, **config
         )
     elif is_file(source):
         return backend['kvitems_gen'](
             source, prefix, map_type=map_type, buf_size=buf_size, **config
         )
     elif is_iterable(source):
         return utils.coros2gen(source,
             (backend['kvitems_basecoro'], (prefix,), {'map_type': map_type})
         )
     raise ValueError("Unknown source type: %r" % type(source))
Exemplo n.º 7
0
def items(events, prefix, map_type=None):
    """Like ijson.items, but takes events generated via ijson.parse instead of
    a file"""
    return utils.coros2gen(events, (items_basecoro, (prefix, ), {
        'map_type': map_type
    }))
Exemplo n.º 8
0
def parse(events):
    """Like ijson.parse, but takes events generated via ijson.basic_parse instead
    of a file"""
    return utils.coros2gen(events, (parse_basecoro, (), {}))
Exemplo n.º 9
0
 def items(f, prefix, map_type=None, buf_size=64 * 1024, **config):
     return utils.coros2gen(
         file_source(f, use_string_reader, buf_size=buf_size),
         *_items_pipeline(backend, prefix, map_type, config))
Exemplo n.º 10
0
 def parse(f, buf_size=64 * 1024, **config):
     return utils.coros2gen(
         file_source(f, use_string_reader, buf_size=buf_size),
         *_parse_pipeline(backend, config))
Exemplo n.º 11
0
 def parse_gen(file_obj, buf_size=64*1024, **config):
     return utils.coros2gen(
         file_source(file_obj, buf_size=buf_size),
         *_parse_pipeline(backend, config)
     )