From 197c2598bc25e58001b029b9ed91ab0823fbf18a Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 5 Aug 2009 16:06:33 +0200 Subject: [PATCH] Moved prop_table to Table.from_items. --- cnetworkmanager | 10 ++-------- networkmanager/util.py | 7 +++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cnetworkmanager b/cnetworkmanager index caad32a..cbfb701 100755 --- a/cnetworkmanager +++ b/cnetworkmanager @@ -143,12 +143,6 @@ def get_device(dev_spec, hint): print "Device '%s' not found" % dev_spec return None -def prop_table(obj, *prop_names): - t = Table("Property", "Value") - for p in prop_names: - t.row(p, obj[p]) - return t - if options.device_info != None: d = get_device(options.device_info, "no hint") if d == None: @@ -164,7 +158,7 @@ if options.device_info != None: elif d._settings_type() == "802-3-ethernet": props.extend(["Carrier"]) - print prop_table(d, *props) + print Table.from_items(d, *props) if options.ap_list: devs = nm.GetDevices() @@ -184,7 +178,7 @@ if options.ap_info != None: aap = dev["ActiveAccessPoint"] for ap in dev.GetAccessPoints(): if ap["HwAddress"] == options.ap_info: - t = prop_table(ap, "Flags", "WpaFlags", "RsnFlags", + t = Table.from_items(ap, "Flags", "WpaFlags", "RsnFlags", "Ssid", "Frequency", "HwAddress", "Mode", "MaxBitrate", "Strength") t.row("Active", ap.object_path == aap.object_path) diff --git a/networkmanager/util.py b/networkmanager/util.py index 4391fc3..83595e0 100644 --- a/networkmanager/util.py +++ b/networkmanager/util.py @@ -101,6 +101,13 @@ class Table(object): self.rows = [] @staticmethod + def from_items(obj, *items): + t = Table("Property", "Value") + for i in items: + t.row(i, obj[i]) + return t + + @staticmethod def from_nested_dict(dd): t = Table("Section", "Property", "Value") for s, d in dd.iteritems(): -- 2.11.4.GIT