Skip to content

Commit

Permalink
Write out compressed JSON output
Browse files Browse the repository at this point in the history
... and properly close the file if writing to disk.
  • Loading branch information
mjs committed Apr 12, 2019
1 parent 8eed0a4 commit 9a103b7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions classify/clipclassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def get_meta_data(self, filename):
elif len(tags) == 1:
tag = tags[0] if tags[0] else "none"
else:
print(tags)
tag = 'multi'
meta_data["primary_tag"] = tag
return meta_data
Expand Down Expand Up @@ -344,8 +343,7 @@ def save_metadata(self, filename, meta_filename, tracker):
track_info['positions'] = positions

if self.config.classify.meta_to_stdout:
output = json.dumps(save_file, indent=4, cls=tools.CustomJSONEncoder)
print(output)
print(json.dumps(save_file, cls=tools.CustomJSONEncoder))
else:
f = open(meta_filename, 'w')
json.dump(save_file, f, indent=4, cls=tools.CustomJSONEncoder)
with open(meta_filename, 'w') as f:
json.dump(save_file, f, indent=4, cls=tools.CustomJSONEncoder)

0 comments on commit 9a103b7

Please sign in to comment.