Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reg_apikey(service, apikey):
"""Register API-KEY."""
try:
config.add_apikey(service, apikey)
except:
pass
def do_pipe():
"""Read isbn from pipe."""
if sys.stdin.isatty():
return 1
service, fmt, apikey = (None, None, None)
if len(sys.argv) > 1:
args = sys.argv[1:]
_, service, fmt, apikey = parse_args(args)
service = service if service else 'default'
fmt = fmt if fmt else 'labels'
if apikey:
try:
config.add_apikey(service, apikey)
except:
pass
for line in sys.stdin:
line = line.strip()
uprint((fmtbib(fmt, meta(line, service))))
return 0
def do_terminal(args=None):
"""Read isbn from terminal."""
args = sys.argv[1:] if not args else args[1:]
isbn, service, fmt, apikey = parse_args(args)
if not isbn:
raise
service = service if service else 'default'
fmt = fmt if fmt else 'labels'
if apikey:
try:
config.add_apikey(service, apikey)
except:
pass
r = meta(isbn, service)
uprint((fmtbib(fmt, r)))
return 0