def _import_glob_lazy_list(pattern, extension_map, max_assets=None,
                           landmark_resolver=same_name, shuffle=False,
                           as_generator=False, landmark_ext_map=None,
                           landmark_attach_func=None, importer_kwargs=None,
                           verbose=False):
    filepaths = list(glob_with_suffix(pattern, extension_map,
                                      sort=(not shuffle)))
    if shuffle:
        random.shuffle(filepaths)
    if (max_assets is not None) and max_assets <= 0:
        raise ValueError('Max elements should be positive'
                         ' ({} provided)'.format(max_assets))
    elif max_assets:
        filepaths = filepaths[:max_assets]
    n_files = len(filepaths)
    if n_files == 0:
        raise ValueError('The glob {} yields no assets'.format(pattern))

    lazy_list = LazyList([partial(_import, f, extension_map,
                                  landmark_resolver=landmark_resolver,
                                  landmark_ext_map=landmark_ext_map,
                                  landmark_attach_func=landmark_attach_func,
                                  importer_kwargs=importer_kwargs)
                          for f in filepaths])

    if verbose and as_generator:
        # wrap the generator with the progress reporter
        lazy_list = print_progress(lazy_list, prefix='Importing assets',
                                   n_items=n_files)
    elif verbose:
        print('Found {} assets, index the returned LazyList to import.'.format(
            n_files))

    if as_generator:
        return (a for a in lazy_list)
    else:
        return lazy_list
dataset/ETHPy150Open menpo/menpo/menpo/io/input/base.py/_import_glob_lazy_list/original