Skip to content

Commit

Permalink
Add a __str__ method to idl.Row
Browse files Browse the repository at this point in the history
It's sometimes handy to log an entire Row object, so this just
adds a string representation of the object as:

   Tablename(col1=val1, col2=val2, ..., coln=valn)

Signed-off-by: Terry Wilson <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
otherwiseguy authored and blp committed Sep 25, 2019
1 parent dc0bd12 commit 6a1c984
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/ovs/db/idl.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,12 @@ def __eq__(self, other):
def __hash__(self):
return int(self.__dict__['uuid'])

def __str__(self):
return "{table}({data})".format(
table=self._table.name,
data=", ".join("{col}={val}".format(col=c, val=getattr(self, c))
for c in sorted(self._table.columns)))

def __getattr__(self, column_name):
assert self._changes is not None
assert self._mutations is not None
Expand Down

0 comments on commit 6a1c984

Please sign in to comment.