How to use the isbntools.app.canonical function in isbntools

To help you get started, we’ve selected a few isbntools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xlcnd / isbntools / isbntools / bin / meta.py View on Github external
def parse_args(args):
    """Parse args from command line."""
    service = None
    api = None
    fmt = None
    isbn = get_canonical_isbn(canonical(clean(args[0])))
    if len(args) == 1 and isbn:
        return (isbn, service, fmt, api)
    if isbn:
        del args[0]
    providers = list(registry.services.keys())
    for a in args:
        match = get_close_matches(a, fmts)
        if len(match) == 1:
            fmt = match[0]
            args.remove(a)
            break
    for a in args:
        match = get_close_matches(a, providers)
        if len(match) == 1:
            service = match[0]
            args.remove(a)
github xlcnd / isbntools / isbntools / bin / ren.py View on Github external
def parse_args(args):
    """Parse and return a tuple of the command line arguments."""
    fn = args[-1]
    service = None
    key = None
    isbn = None
    pattern = None
    if len(args) == 1:
        return (isbn, service, key, pattern, fn)
    isbn = get_canonical_isbn(canonical(clean(args[0])))
    providers = list(registry.services.keys())
    if isbn:
        args.pop(0)
    if args[0] != fn:
        service = args[0]
        match = get_close_matches(service, providers)
        if len(match) == 1 and '{' not in args[0]:  # <- rule out placeholders
            service = match[0]
        else:
            service = None
            pattern = args[0]
        key = None if args[1] == fn else args[1]
        if key and '{' in key:
            pattern = key
            key = None
        if not args[1] == fn: