File: gh-get.py

package info (click to toggle)
tikzit 2.1.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,104 kB
  • sloc: cpp: 8,492; yacc: 226; lex: 194; sh: 77; python: 68; makefile: 9; xml: 7
file content (22 lines) | stat: -rwxr-xr-x 529 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python

from gh import gh, pr
import sys, os

filter = None
if len(sys.argv) == 2:
	filter = sys.argv[1]

tok = os.getenv('GITHUB_TOKEN')

draft = [r for r in gh('releases') if r['draft']][0]

for a in draft['assets']:
	if filter == None or filter in a['name']:
		print('Downloading ' + a['name'])
		b = gh('releases/assets/%s?access_token=%s' % (a['id'], tok),
			   ['-L', '-H', 'Accept: application/octet-stream'],
			   parse=False, quiet=False, auth=False)
		f = open(a['name'], 'w')
		f.write(b)
		f.close()