Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
"""
# 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
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))