-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathupdate.py
More file actions
52 lines (42 loc) · 1.48 KB
/
update.py
File metadata and controls
52 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import html.parser
import urllib.request
import json
import sys
url = "http://dev.overpass-api.de/releases/"
skip_prefixes = (
'v0.6', 'beta', 'v0.7.1', 'v0.7.2', 'v0.7.3', 'v0.7.4', 'v0.7.50', 'v0.7.52',
'v0.7.54.11', # invalid CRC in archive
'v0.7.51', # no autoconf
)
class VersionFinder(html.parser.HTMLParser):
def error(self, message):
raise RuntimeError(message)
def __init__(self):
super().__init__()
self.versions = []
def handle_starttag(self, tag, attrs):
if attrs:
href = dict(attrs).get('href')
if tag == 'a' and href and href.startswith('osm-3s'):
version = href[len('osm-3s_'):-len('.tar.gz')]
self.versions.append(version)
def versions_to_build():
parser = VersionFinder()
response = urllib.request.urlopen(url)
data = response.read().decode(response.headers.get_content_charset())
parser.feed(data)
return list(sorted([
version for version in parser.versions
if version != 'v0.7'
and not any(version.startswith(skip_prefix) for skip_prefix in skip_prefixes)
]))
if __name__ == '__main__':
versions = versions_to_build()
if len(sys.argv) > 1 and sys.argv[1]:
filter_predicate = lambda x: x > sys.argv[1]
else:
filter_predicate = lambda x: True
github_matrix = {
"include": [{"version": v} for v in versions if filter_predicate(v)]
}
print(json.dumps(github_matrix, indent=None))