-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyApt2Metalink
More file actions
executable file
·28 lines (25 loc) · 887 Bytes
/
pyApt2Metalink
File metadata and controls
executable file
·28 lines (25 loc) · 887 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
if __name__ == "__main__":
entries = []
while True:
line = sys.stdin.readline()
if not line: break
uri, name, size, chksum = line.split()
uri = re.sub(r"^'|'$", "", uri)
hashfunc, hashvalue = chksum.split(':')
hashfunc = hashfunc.lower()
if hashfunc == 'sha256':
hashfunc = 'sha-256'
entries.append((uri, name, size, hashfunc, hashvalue))
print """<?xml version="1.0" encoding="UTF-8"?>
<metalink xmlns="urn:ietf:params:xml:ns:metalink">"""
for e in entries:
print """<file name="{name}">
<size>{size}</size>
<hash type="{hashfunc}">{hashvalue}</hash>
<url priority="1">{uri}</url>
</file>""".format(uri=e[0],name=e[1], size=e[2], hashfunc=e[3], hashvalue=e[4])
print """</metalink>"""