Make script Python3 compatible

alfred-data
Matthias Schiffer 2012-04-28 23:06:34 +02:00
parent aabaabc67a
commit cd7b9cf235
1 changed files with 17 additions and 16 deletions

View File

@ -4,7 +4,7 @@
# Gatewayliste # Gatewayliste
# aliases.json # aliases.json
import simplejson as json import json
import fileinput import fileinput
import argparse import argparse
@ -128,6 +128,7 @@ if options['aliases']:
if 'group' in alias: if 'group' in alias:
node.group = alias['group'] node.group = alias['group']
if options['gateway']:
for gateway in options['gateway']: for gateway in options['gateway']:
try: try:
node = maybe_node_by_mac(nodes, (gateway, )) node = maybe_node_by_mac(nodes, (gateway, ))
@ -149,16 +150,16 @@ def map_link(nodes, pair):
return link return link
links = map(lambda x: map_link(nodes, x), links) links = [map_link(nodes, x) for x in links]
output = dict() output = dict()
output['nodes'] = map(lambda x: {'group': x.group, 'name': x.name, output['nodes'] = [{'group': x.group, 'name': x.name,
'macs': ', '.join(x.macs) 'macs': ', '.join(x.macs)
}, nodes) } for x in nodes]
output['links'] = map(lambda x: {'source': x.pair[0], 'target': x.pair[1], output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
'distance': x.distance, 'distance': x.distance,
'strength': x.strength 'strength': x.strength
}, links) } for x in links]
print json.dumps(output) print(json.dumps(output))