How to use the isbntools.app.get_canonical_isbn 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 / validate.py View on Github external
def do_pipe():
    """Validate ISBNs from sys.stdin."""
    # check if pipe
    if sys.stdin.isatty():
        print('Usage:\n   cat ISBNs | isbn_validate')
        return 1
    for line in sys.stdin:
        line = line.strip()
        buf = re.sub(r"\[|\]|'|-", "", repr(get_isbnlike(line)))
        buf = buf.strip()
        if ',' in buf:
            for b in buf.split(','):
                b = get_canonical_isbn(b.strip())
                if b:
                    print(b)
        else:
            buf = get_canonical_isbn(buf)
            if buf:
                print(buf)
    return 0
github xlcnd / isbntools / isbntools / bin / stdin_validate.py View on Github external
It will output all valid ISBNs that receive from input.

    Usage:
    cat ISBNs| isbn_stdin_validate
    """
    # check if pipe
    if sys.stdin.isatty():
        print('Usage:\n   cat ISBNs| isbn_stdin_validate')
        return 1
    for line in sys.stdin:
        line = line.strip()
        buf = re.sub(r"\[|\]|'|-", "", repr(get_isbnlike(line)))
        buf = buf.strip()
        if ',' in buf:
            for b in buf.split(','):
                b = get_canonical_isbn(b.strip())
                if b:
                    print(b)
        else:
            buf = get_canonical_isbn(buf)
            if buf:
                print(buf)
    return 0
github xlcnd / isbntools / isbntools / bin / stdin_validate.py View on Github external
"""
    # check if pipe
    if sys.stdin.isatty():
        print('Usage:\n   cat ISBNs| isbn_stdin_validate')
        return 1
    for line in sys.stdin:
        line = line.strip()
        buf = re.sub(r"\[|\]|'|-", "", repr(get_isbnlike(line)))
        buf = buf.strip()
        if ',' in buf:
            for b in buf.split(','):
                b = get_canonical_isbn(b.strip())
                if b:
                    print(b)
        else:
            buf = get_canonical_isbn(buf)
            if buf:
                print(buf)
    return 0
github xlcnd / isbntools / isbntools / bin / repl.py View on Github external
def _parse(self, comand, line):
        """Parse line as sys.argv."""
        # get/set last_isbn
        if self.last_isbn:
            line = line.replace(self.last_isbn_ph, self.last_isbn)
        isbn = get_canonical_isbn(line)
        if isbn:
            self.last_isbn = isbn
        # handle redirecion
        ops = ['<', '>', '>>', '|']
        redirect = any(x in line for x in ops)
        if redirect:
            if '<' in line:
                print('*** Input redirection is not supported!')
                return
            if comand == 'audit':
                comand = 'isbntools'
            elif comand.startswith('to_isbn'):
                pass
            else:
                comand = 'isbn_' + comand
            self.do_shell('%s %s' % (comand, line))