-
Notifications
You must be signed in to change notification settings - Fork 287
Expand file tree
/
Copy pathgenerateUpdatesXml.py
More file actions
37 lines (31 loc) · 1.07 KB
/
generateUpdatesXml.py
File metadata and controls
37 lines (31 loc) · 1.07 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
import json
import re
import sys
if __name__ == '__main__':
arg = sys.argv[1:][0]
if arg == '-':
data = json.load(sys.stdin)
else:
with open(arg) as f:
data = json.load(f)
xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<plugins>']
buildRegex = r'.*(\d{3}).zip'
# given plugin-amazonq-3.39-SNAPSHOT-1731096007-241.zip,
# capture 3.39-SNAPSHOT-1731096007-241 in group 1
# or
# given plugin-amazonq-3.39-SNAPSHOT-1731096007.241.zip,
# capture 3.39-SNAPSHOT-1731096007.241 in group 1
versionRegex = r'.*?\-(\d.*[.-]\d{3})\.zip$'
for asset in data['assets']:
name = asset['name']
plugin = 'aws.toolkit'
build = re.match(buildRegex, name)
if build == None:
continue
build = build.group(1)
version = re.match(versionRegex, name).group(1)
xml.append(f'''<plugin id="{plugin}" url="{asset['url']}" version="{version}">
<idea-version since-build="{build}" until-build="{build}.*"/>
</plugin>''')
xml.append('</plugins>')
print('\n'.join(xml))