using click.echo's built in file-handling

This commit is contained in:
2019-02-20 12:16:23 -05:00
parent d5ce3d6583
commit e2620ade65
2 changed files with 6 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ with open('README.md') as file:
setup(
name="tatt",
version="0.949",
version="0.950",
py_modules=['tatt'],
url='https://github.com/zevaverbach/tatt',
install_requires=[

View File

@@ -25,12 +25,11 @@ def get(name, save):
except exceptions.NotAvailable as e:
raise click.ClickException(str(e))
if not save:
click.echo(transcript)
else:
with open(f'{name}.json', 'w') as fout:
fout.write(transcript)
click.echo(f'Okay, downloaded {name}.json')
filepath = None
if save:
filepath = f'{name}.json', 'w'
click.echo(transcript, file=filepath)