<s> import json , datetime <EOL> from json_helpers import extract_datetime <EOL> ORG = '<STR_LIT>' <EOL> REPO = '<STR_LIT>' <EOL> FILENAME_ISSUES = ORG + '<STR_LIT>' <EOL> BUG_LABEL = [ '<STR_LIT>' ] <EOL> CRITICAL_BUG_LABEL = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> APP_LABEL = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> one_day = datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> now = datetime . datetime . now ( datetime . timezone . utc ) <EOL> f = open ( FILENAME_ISSUES ) <EOL> data = json . load ( f ) <EOL> f . close ( ) <EOL> if REPO not in data . keys ( ) and len ( data [ REPO ] ) == <NUM_LIT:0> : <EOL> raise SystemExit ( ) <EOL> for i in data [ REPO ] . keys ( ) : <EOL> data [ REPO ] [ i ] [ '<STR_LIT>' ] = extract_datetime ( data [ REPO ] [ i ] [ '<STR_LIT>' ] ) <EOL> if data [ REPO ] [ i ] [ '<STR_LIT>' ] is not None : <EOL> data [ REPO ] [ i ] [ '<STR_LIT>' ] = extract_datetime ( data [ REPO ] [ i ] [ '<STR_LIT>' ] ) <EOL> last_number = min ( [ int ( i ) for i in data [ REPO ] . keys ( ) ] ) <EOL> first_date = extract_datetime ( data [ REPO ] [ str ( last_number ) ] [ '<STR_LIT>' ] ) <EOL> day = datetime . datetime ( first_date . year , first_date . month , first_date . day , tzinfo = datetime . timezone . utc ) <EOL> day += one_day <EOL> result = { } <EOL> f = open ( '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> f . write ( '<STR_LIT>' % '<STR_LIT:\t>' . join ( APP_LABEL ) ) <EOL> while day < now : <EOL> key = day . strftime ( '<STR_LIT>' ) <EOL> print ( key ) <EOL> open_pr_count = <NUM_LIT:0> <EOL> closed_pr_count = <NUM_LIT:0> <EOL> open_issue_count = <NUM_LIT:0> <EOL> closed_issue_count = <NUM_LIT:0> <EOL> rating_number = <NUM_LIT:0> <EOL> rating_apps = { } <EOL> for app in APP_LABEL : <EOL> rating_apps [ app ] = <NUM_LIT:0> <EOL> for i in data [ REPO ] : <EOL> element = data [ REPO ] [ i ] <EOL> if element [ '<STR_LIT>' ] > day : <EOL> continue <EOL> is_open = True <EOL> if isinstance ( element [ '<STR_LIT>' ] , datetime . datetime ) and element [ '<STR_LIT>' ] < day : <EOL> is_open = False <EOL> if element [ '<STR_LIT>' ] : <EOL> if is_open : <EOL> open_pr_count += <NUM_LIT:1> <EOL> else : <EOL> closed_pr_count += <NUM_LIT:1> <EOL> else : <EOL> if is_open : <EOL> open_issue_count += <NUM_LIT:1> <EOL> else : <EOL> closed_issue_count += <NUM_LIT:1> <EOL> if is_open : <EOL> rating = <NUM_LIT:1> <EOL> for label in BUG_LABEL : <EOL> if label in element [ '<STR_LIT>' ] : <EOL> rating = <NUM_LIT:10> <EOL> break <EOL> for label in CRITICAL_BUG_LABEL : <EOL> if label in element [ '<STR_LIT>' ] : <EOL> rating = <NUM_LIT:100> <EOL> break <EOL> rating_number += rating <EOL> for app in APP_LABEL : <EOL> if app in element [ '<STR_LIT>' ] : <EOL> rating_apps [ app ] += rating <EOL> output = '<STR_LIT>' % ( key , open_issue_count , closed_issue_count , open_pr_count , closed_pr_count , rating_number ) <EOL> for app in APP_LABEL : <EOL> output += '<STR_LIT>' % rating_apps [ app ] <EOL> f . write ( output + '<STR_LIT:\n>' ) <EOL> day += one_day <EOL> f . close ( ) </s>
