Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit 0b75866

Browse files
Add __repr__ to GroupMod (+4 classes)
Implement a useful repr() in: GroupMod, Header, Bucket, ActionSetField and ActionOutput. Fix #635.
1 parent 7ab425d commit 0b75866

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

‎pyof/v0x04/common/action.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ def __init__(self, port=None,
328328
self.port = port
329329
self.max_length = max_length
330330

331+
def __repr__(self):
332+
return f"{type(self).__name__}(port={self.port})"
333+
331334

332335
class ActionPopMPLS(ActionHeader):
333336
"""Action structure for OFPAT_POP_MPLS."""
@@ -388,6 +391,10 @@ def __init__(self, field=None):
388391
super().__init__(action_type=ActionType.OFPAT_SET_FIELD)
389392
self.field = OxmTLV() if field is None else field
390393

394+
def __repr__(self):
395+
return (f"{type(self).__name__}({self.field.oxm_field!s}, "
396+
f"{self.field.oxm_value})")
397+
391398
def pack(self, value=None):
392399
"""Pack this structure updating the length and padding it."""
393400
self._update_length()

‎pyof/v0x04/common/header.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ def __init__(self, message_type=None, length=None, xid=None):
102102
self.message_type = message_type
103103
self.length = length
104104
self.xid = xid
105+
106+
def __repr__(self):
107+
return (f"{type(self).__name__}(version={self.version}, "
108+
f"xid={self.xid}, {self.message_type!s})")

‎pyof/v0x04/controller2switch/common.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ def __init__(self, length=None, weight=None, watch_port=None,
224224
self.watch_group = watch_group
225225
self.actions = actions
226226

227+
def __repr__(self):
228+
return f"{type(self).__name__}(actions={self.actions!r})"
229+
227230
def unpack(self, buff, offset=0):
228231
"""Unpack bucket.
229232

‎pyof/v0x04/controller2switch/group_mod.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,8 @@ def __init__(self, xid=None, command=None, group_type=None, group_id=None,
9191
self.group_type = group_type
9292
self.group_id = group_id
9393
self.buckets = buckets
94+
95+
def __repr__(self):
96+
return (f"{type(self).__name__}(xid={self.header.xid}, {self.command},"
97+
f" group_type={self.group_type}, group_id={self.group_id},"
98+
f" buckets={self.buckets!r})")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /