Esempio n. 1
0
def main(cmd, args):
    """Command Line interface for generating dumps."""
    iargs = iter(args)

    args = []
    kwargs = {}

    for a in iargs:
        if a.startswith("--"):
            name = a[2:].replace("-", "_")
            value = next(iargs)
            kwargs[name] = value
        else:
            args.append(a)

    func = {
        "cdump": generate_cdump,
        "dump": generate_dump,
        "idump": generate_idump,
        "sort": sort_dump,
        "split": split_dump,
        "index": make_index,
        "sitemaps": generate_sitemaps,
        "htmlindex": generate_html_index,
    }.get(cmd)
    if func:
        func(*args, **kwargs)
    elif cmd == "solrdump":
        from openlibrary.data import solr  # noqa: E402 avoid circular import
        solr.generate_dump(*args, **kwargs)
    else:
        logger.error(f"Unknown command: {cmd}")
        print("Unknown command:", cmd, file=sys.stderr)
Esempio n. 2
0
def main(cmd, args):
    """Command Line interface for generating dumps.
    """
    iargs = iter(args)

    args = []
    kwargs = {}

    for a in iargs:
        if a.startswith('--'):
            name = a[2:].replace("-", "_")
            value = next(iargs)
            kwargs[name] = value
        else:
            args.append(a)

    if cmd == 'cdump':
        generate_cdump(*args, **kwargs)
    elif cmd == 'dump':
        generate_dump(*args, **kwargs)
    elif cmd == 'idump':
        generate_idump(*args, **kwargs)
    elif cmd == 'sort':
        sort_dump(*args, **kwargs)
    elif cmd == 'split':
        split_dump(*args, **kwargs)
    elif cmd == 'index':
        make_index(*args, **kwargs)
    elif cmd == 'bsddb':
        make_bsddb(*args, **kwargs)
    elif cmd == "solrdump":
        from openlibrary.data import solr  # noqa: E402 avoid circular import
        solr.generate_dump(*args, **kwargs)
    elif cmd == 'sitemaps':
        generate_sitemaps(*args, **kwargs)
    elif cmd == 'htmlindex':
        generate_html_index(*args, **kwargs)
    else:
        print("Unknown command:", cmd, file=sys.stderr)