Created
June 1, 2015 15:36
-
-
Save stuartcampbell/f70fbda046791fca7f25 to your computer and use it in GitHub Desktop.
Iterating over 3 lines at a time (for stdout) in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import itertools | |
| # execute some command | |
| since = "--since='{0}-{1}-1'".format(str(year), str(month)) | |
| until = "--before='{0}-{1}-{2}'".format(str(year), str(month), str(days_in_month[month-1])) | |
| args = ['git', 'log', '--pretty=format:"%ai %aE"', '--shortstat', since, until] | |
| sub = subprocess.Popen(args, stdout=subprocess.PIPE, close_fds=True, cwd='/path/to/git/repo/clone') | |
| for line1,line2,line3 in itertools.izip_longest(*[sub.stdout]*3): | |
| # Do stuff with line1, line2, line3... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment