import requests
import collections

dists = ['jessie', 'stretch']
aptly_dists = [d + '-tools' for d in dists]

platforms = ['all', 'amd64']

url = 'http://tools-sge-services-03.tools.eqiad.wmflabs/repo/dists/{dist}/main/binary-{platform}/Packages'

packages = collections.defaultdict(dict)

for dist in aptly_dists:
    for platform in platforms:
        u = url.format(dist=dist, platform=platform)
        req = requests.get(u)
        req.encoding = 'utf-8'
        if not req.ok:
            print('Failed getting ' + u)
            continue
            
        p_data = req.text
        # print(p_data)
        for line in p_data.split("\n"):
            if line.startswith('Package:'):
                package = line.split(": ")[1]
            if line.startswith('Version:'):
                version = line.split(": ")[1]
                if dist not in packages[package]:
                    packages[package][dist] = []
                packages[package][dist].append(version)

# output wikitable with versions
def newrow():
    print('|-')

print('{| class="wikitable sortable"')
newrow()

print("! package")
for dist in dists:
    print("! " + dist)

for package in sorted(packages):
    newrow()
    print("| " + package)
    for d, ad in zip(dists, aptly_dists):
        print("| " + max(packages[package].get(ad, []), default=''))
        
print('|}')
    
{| class="wikitable sortable"
|-
! package
! jessie
! stretch
|-
| docker-engine
| 1.12.6-0~debian-jessie
| 
|-
| jobutils
| 1.7
| 1.36
|-
| kubernetes-client
| 1.4.6-6
| 
|-
| kubernetes-master
| 1.4.6-6
| 
|-
| kubernetes-node
| 1.4.6-6
| 
|-
| misctools
| 1.7
| 1.37
|-
| prometheus-blackbox-exporter
| 0.2.0
| 
|-
| toollabs-webservice
| 0.9
| 0.9
|-
| tools-manifest
| 0.19
| 0.19
|}