<s> import json <EOL> import py <EOL> import textwrap <EOL> issues_url = "<STR_LIT>" <EOL> import requests <EOL> def get_issues ( ) : <EOL> issues = [ ] <EOL> url = issues_url <EOL> while <NUM_LIT:1> : <EOL> get_data = { "<STR_LIT:state>" : "<STR_LIT:all>" } <EOL> r = requests . get ( url , params = get_data ) <EOL> data = r . json ( ) <EOL> if r . status_code == <NUM_LIT> : <EOL> print ( data [ '<STR_LIT:message>' ] ) <EOL> exit ( <NUM_LIT:1> ) <EOL> issues . extend ( data ) <EOL> links = requests . utils . parse_header_links ( r . headers [ '<STR_LIT>' ] ) <EOL> another_page = False <EOL> for link in links : <EOL> if link [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> url = link [ '<STR_LIT:url>' ] <EOL> another_page = True <EOL> if not another_page : <EOL> return issues <EOL> def main ( args ) : <EOL> cachefile = py . path . local ( args . cache ) <EOL> if not cachefile . exists ( ) or args . refresh : <EOL> issues = get_issues ( ) <EOL> cachefile . write ( json . dumps ( issues ) ) <EOL> else : <EOL> issues = json . loads ( cachefile . read ( ) ) <EOL> open_issues = [ x for x in issues if x [ "<STR_LIT:state>" ] == "<STR_LIT>" ] <EOL> open_issues . sort ( key = lambda x : x [ "<STR_LIT>" ] ) <EOL> report ( open_issues ) <EOL> def _get_kind ( issue ) : <EOL> labels = [ l [ '<STR_LIT:name>' ] for l in issue [ '<STR_LIT>' ] ] <EOL> for key in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if key in labels : <EOL> return key <EOL> return '<STR_LIT>' <EOL> def report ( issues ) : <EOL> for issue in issues : <EOL> title = issue [ "<STR_LIT:title>" ] <EOL> body = issue [ "<STR_LIT:body>" ] <EOL> kind = _get_kind ( issue ) <EOL> status = issue [ "<STR_LIT:state>" ] <EOL> number = issue [ "<STR_LIT>" ] <EOL> link = "<STR_LIT>" % number <EOL> print ( "<STR_LIT>" ) <EOL> print ( status , kind , link ) <EOL> print ( title ) <EOL> print ( "<STR_LIT>" % len ( issues ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import argparse <EOL> parser = argparse . ArgumentParser ( "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , action = "<STR_LIT:store>" , default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> args = parser . parse_args ( ) <EOL> main ( args ) </s>
