<s> """<STR_LIT>""" <EOL> import sys <EOL> import json <EOL> import itertools <EOL> import subprocess <EOL> from collections import defaultdict <EOL> def sanitize_author ( name , email ) : <EOL> """<STR_LIT>""" <EOL> return name <EOL> def get_commits ( git_path ) : <EOL> """<STR_LIT>""" <EOL> proc = subprocess . Popen ( <EOL> [ "<STR_LIT>" , "<STR_LIT>" % git_path , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] , <EOL> stdout = subprocess . PIPE ) <EOL> line_stack = [ ] <EOL> def peek_line ( ) : <EOL> if not line_stack : <EOL> line_stack . append ( proc . stdout . readline ( ) ) <EOL> return line_stack [ - <NUM_LIT:1> ] <EOL> def pop_line ( ) : <EOL> if line_stack : <EOL> return line_stack . pop ( ) <EOL> return proc . stdout . readline ( ) <EOL> def push_line ( line ) : <EOL> line_stack . append ( line ) <EOL> def read_commit ( ) : <EOL> while peek_line ( ) and not peek_line ( ) . strip ( ) : <EOL> pop_line ( ) <EOL> if not peek_line ( ) : return None <EOL> assert peek_line ( ) . strip ( ) == "<STR_LIT>" <EOL> pop_line ( ) <EOL> date = int ( pop_line ( ) ) <EOL> name = pop_line ( ) . strip ( ) <EOL> email = pop_line ( ) . strip ( ) <EOL> author = sanitize_author ( name , email ) <EOL> if peek_line ( ) . strip ( ) == "<STR_LIT>" : <EOL> return date , author , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> <EOL> pop_line ( ) <EOL> insertion_count = <NUM_LIT:0> <EOL> deletion_count = <NUM_LIT:0> <EOL> file_count = <NUM_LIT:0> <EOL> while peek_line ( ) . strip ( ) and peek_line ( ) . strip ( ) != "<STR_LIT>" : <EOL> insertions , deletions , path = pop_line ( ) . strip ( ) . split ( None , <NUM_LIT:2> ) <EOL> if insertions == "<STR_LIT:->" : insertions = <NUM_LIT:0> <EOL> if deletions == "<STR_LIT:->" : deletions = <NUM_LIT:0> <EOL> insertion_count += int ( insertions ) <EOL> deletion_count += int ( deletions ) <EOL> file_count += <NUM_LIT:1> <EOL> return date , author , insertion_count , deletion_count , file_count <EOL> while True : <EOL> commit = read_commit ( ) <EOL> if commit is None : <EOL> break <EOL> yield commit <EOL> def main ( ) : <EOL> if len ( sys . argv ) > <NUM_LIT:1> : <EOL> git_path = sys . argv [ <NUM_LIT:1> ] <EOL> else : <EOL> git_path = "<STR_LIT:.>" <EOL> for date , author , insertions , deletions , _ in get_commits ( git_path ) : <EOL> print date , insertions + deletions , author <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
