File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ # If TestPyPI complains about size of packages reaching the quota, use Developer Tools to find out
2
+ # the session ID (in `Cookie:` header) and CSRF token (in any form submission), and use this script
3
+ # to trim old files. THIS OPERATION CANNOT BE UNDONE.
4
+
5
+ session_id = "<insert-session-id-here>"
6
+ csrf_token = "<insert-csrf-token-here>"
7
+
8
+ projects = []
9
+ versions = []
10
+
11
+ import urllib .parse
12
+ import urllib .request
13
+
14
+ for version in versions :
15
+ for project in projects :
16
+ request = urllib .request .Request (
17
+ f"https://test.pypi.org/manage/project/{ project } /release/{ version } /" ,
18
+ method = "POST" ,
19
+ headers = {
20
+ "Cookie" : f"session_id={ session_id } " ,
21
+ "Origin" : "https://test.pypi.org" ,
22
+ },
23
+ data = urllib .parse .urlencode ({
24
+ "csrf_token" : csrf_token ,
25
+ "confirm_delete_version" : version ,
26
+ }).encode ()
27
+ )
28
+ urllib .request .urlopen (request )
29
+ print (f"deleted { project } { version } " )
You can’t perform that action at this time.
0 commit comments