1
1
"""
2
- Find number of open CPython issues per core dev .
2
+ Find number of open issues/PRs in the Python org team .
3
3
"""
4
4
5
5
# /// script
@@ -60,6 +60,18 @@ def check_issues(author: str | None = None) -> Author:
60
60
return Author (issues , prs )
61
61
62
62
63
+ def markdown_link (url : str , text : str | int ) -> str :
64
+ return f"[{ text } ]({ url } )"
65
+
66
+
67
+ def terminal_link (url : str , text : str | int ) -> str :
68
+ return f"\033 ]8;;{ url } \033 \\ { text } \033 ]8;;\033 \\ "
69
+
70
+
71
+ def no_link (url : str , text : str | int ) -> str :
72
+ return str (text )
73
+
74
+
63
75
def main () -> None :
64
76
parser = argparse .ArgumentParser (
65
77
description = __doc__ ,
@@ -107,10 +119,9 @@ def main() -> None:
107
119
field_names = ["" , "Author" , "Issues" , "PRs" , "Total" ]
108
120
if args .markdown :
109
121
table .set_style (TableStyle .MARKDOWN )
110
- elif args .links :
111
- table .align ["Issues link" ] = "l"
112
- table .align ["PRs link" ] = "l"
113
- field_names .extend (["Issues link" , "PRs link" ])
122
+ else :
123
+ table .set_style (TableStyle .SINGLE_BORDER )
124
+
114
125
table .field_names = field_names
115
126
116
127
print ()
@@ -124,26 +135,22 @@ def main() -> None:
124
135
if x or y :
125
136
match (args .markdown , args .links ):
126
137
case True , True :
127
- row = (
128
- i ,
129
- author ,
130
- f"[{ x } ](https://github.com/python/cpython/issues/{ author } )" ,
131
- f"[{ y } ](https://github.com/python/cpython/pulls/{ author } )" ,
132
- f"[{ x + y } ](https://github.com/python/cpython/"
133
- f"issues?q=is%3Aopen+author%3A{ author } )" ,
134
- )
138
+ link_function = markdown_link
135
139
case False , True :
136
- row = (
137
- i ,
138
- author ,
139
- x ,
140
- y ,
141
- x + y ,
142
- f"https://github.com/python/cpython/issues/{ author } " ,
143
- f"https://github.com/python/cpython/pulls/{ author } " ,
144
- )
140
+ link_function = terminal_link
145
141
case _:
146
- row = (i , author , x , y , x + y )
142
+ link_function = no_link
143
+
144
+ row = (
145
+ i ,
146
+ author ,
147
+ link_function (f"https://github.com/python/cpython/issues/{ author } " , x ),
148
+ link_function (f"https://github.com/python/cpython/pulls/{ author } " , y ),
149
+ link_function (
150
+ f"https://github.com/python/cpython/issues?q=is%3Aopen+author%3A{ author } " ,
151
+ x + y ,
152
+ ),
153
+ )
147
154
148
155
table .add_row (row )
149
156
@@ -154,8 +161,6 @@ def main() -> None:
154
161
f"{ total_prs :,} " ,
155
162
f"{ total_issues + total_prs :,} " ,
156
163
]
157
- if args .links and not args .markdown :
158
- total_row .extend (["" , "" ])
159
164
160
165
table .add_row (total_row )
161
166
print (table )
0 commit comments