Changeset 201 for etherws/trunk
- Timestamp:
- 08/01/12 11:38:43 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
etherws/trunk/etherws.py
r200 r201 767 767 768 768 def maxlen(dict_, key, min_): 769 if not dict_: 770 return min_ 769 771 max_ = max(len(str(r[key])) for r in dict_) 770 772 return min_ if max_ < min_ else max_ … … 834 836 return 835 837 result = result['result']['entries'] 838 pmax = maxlen(result, 'port', 4) 836 839 vmax = maxlen(result, 'vid', 4) 837 840 mmax = maxlen(result, 'mac', 3) 838 pmax = maxlen(result, 'port', 4)839 841 amax = maxlen(result, 'age', 3) 840 fmt = ' %%%ds %%%ds %% %ds %%%ds' % (vmax, mmax, pmax, amax)841 print(fmt % (' VLAN', 'MAC', 'Port', 'Age'))842 fmt = ' %%%ds %%%ds %%-%ds %%%ds' % (pmax, vmax, mmax, amax) 843 print(fmt % ('Port', 'VLAN', 'MAC', 'Age')) 842 844 for r in result: 843 print(fmt % (r[' vid'], r['mac'], r['port'], r['age']))845 print(fmt % (r['port'], r['vid'], r['mac'], r['age'])) 844 846 845 847 locals()['handle_ctl_' + args.control_method](args)
Note: See TracChangeset
for help on using the changeset viewer.