|
@@ -58,7 +58,7 @@ def row_format(row, width, header):
|
|
|
titlestr = "{: <{w}s}".format(row['title'][:twidth], w=twidth)
|
|
|
systemstr = "{: ^8s}".format(row['system'][:8])
|
|
|
# unowned, physical, digital, both
|
|
|
- ownltr = [' ', 'P', ' D', 'P D']
|
|
|
+ ownltr = [' ', 'P', ' D', 'P D', ' M']
|
|
|
ownstr = "{: <3s}".format(ownltr[row['ownership']])
|
|
|
progltr = {
|
|
|
0: '',
|
|
@@ -83,10 +83,11 @@ def add(title, system, ownership, progress, notes):
|
|
|
try:
|
|
|
db.add_game(game, update=False)
|
|
|
own_clause = (
|
|
|
- "do not own",
|
|
|
- "physically own",
|
|
|
- "digitally own",
|
|
|
- "digitally and physically own",
|
|
|
+ "do not own it",
|
|
|
+ "physically own it",
|
|
|
+ "digitally own it",
|
|
|
+ "digitally and physically own it",
|
|
|
+ "own it in a collection"
|
|
|
)
|
|
|
progress_clause = (
|
|
|
"cannot beat",
|
|
@@ -96,7 +97,7 @@ def add(title, system, ownership, progress, notes):
|
|
|
"have completed",
|
|
|
)
|
|
|
note_clause = "" if len(game.notes) == 0 else " It also has notes."
|
|
|
- click.echo("Added {} for {}. You {} it and {} it.{}".format(
|
|
|
+ click.echo("Added {} for {}. You {} and {} it.{}".format(
|
|
|
game.title,
|
|
|
game.system,
|
|
|
own_clause[game.ownership],
|
|
@@ -293,7 +294,6 @@ def import_file(format, filepath, update):
|
|
|
resolve_path=True,
|
|
|
dir_okay=False,
|
|
|
file_okay=True),
|
|
|
- default=sys.stdout,
|
|
|
required=False,
|
|
|
)
|
|
|
def export_file(format, filepath):
|
|
@@ -316,14 +316,22 @@ def export_file(format, filepath):
|
|
|
for field in game.keys():
|
|
|
g.update({field: game[field]})
|
|
|
game_set.append(g)
|
|
|
- with open(filepath, "w") as fp:
|
|
|
+ if not filepath:
|
|
|
if format == "yaml":
|
|
|
- yaml.dump(game_set, fp, default_flow_style=False,
|
|
|
+ yaml.dump(game_set, sys.stdout, default_flow_style=False,
|
|
|
indent=4, allow_unicode=True)
|
|
|
if format == "json":
|
|
|
- json.dump(game_set, fp, allow_nan=False, indent=1, skipkeys=True, sort_keys=True)
|
|
|
+ json.dump(game_set, sys.stdout, allow_nan=False, indent=1, skipkeys=True, sort_keys=True)
|
|
|
+ else:
|
|
|
+ with open(filepath, "w") as fp:
|
|
|
+ if format == "yaml":
|
|
|
+ yaml.dump(game_set, fp, default_flow_style=False,
|
|
|
+ indent=4, allow_unicode=True)
|
|
|
+ if format == "json":
|
|
|
+ json.dump(game_set, fp, allow_nan=False, indent=1, skipkeys=True, sort_keys=True)
|
|
|
if len(game_set) > 0:
|
|
|
- click.echo("Successfully exported {} games to {}.".format(len(game_set), filepath))
|
|
|
+ if filepath:
|
|
|
+ click.echo("Successfully exported {} games to {}.".format(len(game_set), filepath))
|
|
|
else:
|
|
|
click.echo("Could not export any games; have you made sure your collection has games in it?")
|
|
|
|