action_list: remove show method
Also adds __iter__ so we can use an action_list as a sequence.
diff --git a/src/python/of10/action_list.py b/src/python/of10/action_list.py
index c2ab07e..2c5a906 100644
--- a/src/python/of10/action_list.py
+++ b/src/python/of10/action_list.py
@@ -143,19 +143,12 @@
length += act.__len__()
return length
+ def __iter__(self):
+ return self.actions.__iter__()
+
def __eq__(self, other):
if type(self) != type(other): return False
if self.actions != other.actions: return False
return True
def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- outstr = prefix + "Action List with " + str(len(self.actions)) + \
- " actions\n"
- count = 0
- for obj in self.actions:
- count += 1
- outstr += prefix + " Action " + str(count) + ": \n"
- outstr += obj.show(prefix + ' ')
- return outstr
diff --git a/src/python/of10/message.py b/src/python/of10/message.py
index bf0064e..4f5a43f 100644
--- a/src/python/of10/message.py
+++ b/src/python/of10/message.py
@@ -968,7 +968,8 @@
outstr += self.header.show(prefix + ' ')
outstr += ofp_flow_mod.show(self, prefix)
outstr += prefix + "List actions\n"
- outstr += self.actions.show(prefix + ' ')
+ for obj in self.actions:
+ outstr += obj.show(prefix + " ")
return outstr
def __eq__(self, other):
@@ -1646,7 +1647,8 @@
outstr += self.header.show(prefix + ' ')
outstr += ofp_packet_out.show(self, prefix)
outstr += prefix + "List actions\n"
- outstr += self.actions.show(prefix + ' ')
+ for obj in self.actions:
+ outstr += obj.show(prefix + " ")
outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
##@todo Fix this circular reference
# if len(self.data) > 0:
@@ -2666,7 +2668,9 @@
def show(self, prefix=''):
outstr = prefix + "flow_stats_entry\n"
outstr += ofp_flow_stats.show(self, prefix + ' ')
- outstr += self.actions.show(prefix + ' ')
+ outstr += prefix + "List actions\n"
+ for obj in self.actions:
+ outstr += obj.show(prefix + ' ')
return outstr
def __eq__(self, other):
diff --git a/tools/munger/scripts/message_gen.py b/tools/munger/scripts/message_gen.py
index ff535f7..6761935 100644
--- a/tools/munger/scripts/message_gen.py
+++ b/tools/munger/scripts/message_gen.py
@@ -429,7 +429,8 @@
_p3("outstr += obj.show(prefix + ' ')")
else:
_p2('outstr += prefix + "List ' + list_var + '\\n"')
- _p2('outstr += self.' + list_var + ".show(prefix + ' ')")
+ _p2('for obj in self.' + list_var + ':')
+ _p3('outstr += obj.show(prefix + " ")')
if has_string:
_p2("outstr += prefix + 'data is of length ' + str(len(self.data)) + '\\n'")
_p2("##@todo Fix this circular reference")
@@ -705,7 +706,9 @@
def show(self, prefix=''):
outstr = prefix + "flow_stats_entry\\n"
outstr += ofp_flow_stats.show(self, prefix + ' ')
- outstr += self.actions.show(prefix + ' ')
+ outstr += prefix + "List actions\\n"
+ for obj in self.actions:
+ outstr += obj.show(prefix + ' ')
return outstr
def __eq__(self, other):