Skip to content

Instantly share code, notes, and snippets.

@rhelmer
Created June 4, 2012 17:47
Show Gist options
  • Select an option

  • Save rhelmer/2869796 to your computer and use it in GitHub Desktop.

Select an option

Save rhelmer/2869796 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import shlex
import csv
keys_of_interest = ['build_id','product','release', 'platform']
releases = []
for line in sys.stdin.read().split('\n'):
r = {}
for arg in shlex.split(line):
if '=' in arg:
(key, value) = arg.split('=', 1)
if key in keys_of_interest:
r[key] = value
if r != {}:
releases.append(r)
output = csv.DictWriter(sys.stdout, fieldnames=keys_of_interest)
output.writeheader()
for r in releases:
output.writerow(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment