#!/usr/bin/env python3
readslist = {
'mw': {
'url': 'http://elementscommunity.org/forum/forum-games/elements-mafia-77-by-linkcat/msg1305452/#msg1305452',
'n+': ('sub', 'kaempf', 'shock'),
'n': ('oa', 'www3', 'kdz'),
'n-': ('rob', 'naii', 'anti', 'torb', 'serp'),
},
'serp': {
'url': 'http://elementscommunity.org/forum/forum-games/elements-mafia-77-by-linkcat/msg1305453/#msg1305453',
'v': ('sky', 'torb'),
'n+': ('mw', 'kaempf', 'timpa', 'kdz'),
'n': ('rob', 'oa', 'www3', 'anti'),
'n-': ('shock', 'naii'),
'w': ('sub',)
},
'sub': {
'url': 'http://elementscommunity.org/forum/forum-games/elements-mafia-77-by-linkcat/msg1305465/#msg1305465',
'n+': ('kaempf', 'serp', 'kdz', 'mw', 'shock'),
'n': ('www3', 'torb', 'timpa'),
'n-': ('oa', 'sky')
},
'kaempf': {
'url': 'http://elementscommunity.org/forum/forum-games/elements-mafia-77-by-linkcat/msg1305470/#msg1305470',
'v': ('serp',),
'n+': ('sub', 'shock', 'mw', 'sky'),
'n': ('oa', 'naii', 'www3', 'torb', 'kdz', 'timpa'),
},
'timpa': {
'url': 'http://elementscommunity.org/forum/forum-games/elements-mafia-77-by-linkcat/msg1305477/#msg1305477',
'v': ('kaempf',),
'n+': ('mw', 'sky',),
'n': ('sub', 'www3', 'oa', 'naii', 'kdz', 'shock'),
'n-': ('serp', 'torb'),
},
'naii': {
'url': 'http://elementscommunity.org/forum/forum-games/elements-mafia-77-by-linkcat/msg1305535/#msg1305535',
'n+': ('kaempf', 'sub', 'serp'),
'n': ('oa', 'www3', 'timpa', 'kdz', 'shock', 'sky', 'mw'),
'n-': ('torb',)
}
}
names = list(readslist.keys())
readsmap = {}
readsurl = {}
for name, reads in readslist.items():
for k in reads:
if k == 'url': continue
for readee in reads[k]:
if readee not in names: names.append(readee)
readsmap[name, readee] = k
print('[table]')
print('[tr][td][/td]',end='')
print(''.join(f'[td]{name}[/td]' for name in names), end='')
print('[/tr]', end='')
for reader in names:
reads = readslist.get(reader, None)
url = reads and reads.get('url', None)
if url:
print(f'[tr][td][url={url}]{reader}[/url][/td]', end='')
else:
print(f'[tr][td]{reader}[/td]', end='')
for readee in names:
print('[td]', readsmap.get((reader, readee), ''), '[/td]', sep='', end='')
print('[/tr]')
print('[/table]')