[cli] Explicitly set CSV/TSV line terminator

Fixes #358
This commit is contained in:
derrod 2021-10-21 11:39:11 +02:00
parent 856c5ef2ee
commit 2146a45104

View file

@ -213,7 +213,7 @@ class LegendaryCLI:
dlc_list[citem_id] = sorted(dlc_list[citem_id], key=lambda d: d.app_title.lower()) dlc_list[citem_id] = sorted(dlc_list[citem_id], key=lambda d: d.app_title.lower())
if args.csv or args.tsv: if args.csv or args.tsv:
writer = csv.writer(stdout, dialect='excel-tab' if args.tsv else 'excel') writer = csv.writer(stdout, dialect='excel-tab' if args.tsv else 'excel', lineterminator='\n')
writer.writerow(['App name', 'App title', 'Version', 'Is DLC']) writer.writerow(['App name', 'App title', 'Version', 'Is DLC'])
for game in games: for game in games:
writer.writerow((game.app_name, game.app_title, game.app_version, False)) writer.writerow((game.app_name, game.app_title, game.app_version, False))
@ -270,7 +270,7 @@ class LegendaryCLI:
f'with "--check-updates".') f'with "--check-updates".')
if args.csv or args.tsv: if args.csv or args.tsv:
writer = csv.writer(stdout, dialect='excel-tab' if args.tsv else 'excel') writer = csv.writer(stdout, dialect='excel-tab' if args.tsv else 'excel', lineterminator='\n')
writer.writerow(['App name', 'App title', 'Installed version', 'Available version', writer.writerow(['App name', 'App title', 'Installed version', 'Available version',
'Update available', 'Install size', 'Install path']) 'Update available', 'Install size', 'Install path'])
writer.writerows((game.app_name, game.title, game.version, versions[game.app_name], writer.writerows((game.app_name, game.title, game.version, versions[game.app_name],
@ -353,7 +353,7 @@ class LegendaryCLI:
for fm in files: for fm in files:
print(f'{fm.hash.hex()} *{fm.filename}') print(f'{fm.hash.hex()} *{fm.filename}')
elif args.csv or args.tsv: elif args.csv or args.tsv:
writer = csv.writer(stdout, dialect='excel-tab' if args.tsv else 'excel') writer = csv.writer(stdout, dialect='excel-tab' if args.tsv else 'excel', lineterminator='\n')
writer.writerow(['path', 'hash', 'size', 'install_tags']) writer.writerow(['path', 'hash', 'size', 'install_tags'])
writer.writerows((fm.filename, fm.hash.hex(), fm.file_size, '|'.join(fm.install_tags)) for fm in files) writer.writerows((fm.filename, fm.hash.hex(), fm.file_size, '|'.join(fm.install_tags)) for fm in files)
elif args.json: elif args.json: