From e10538e05c325de9006861da72965acf93b5cfbd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Dec 2014 08:56:41 +0530 Subject: [PATCH] A nicer repr for Tag objects --- src/calibre/gui2/tweak_book/editor/smarts/html.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calibre/gui2/tweak_book/editor/smarts/html.py b/src/calibre/gui2/tweak_book/editor/smarts/html.py index 10f699c37e..173f53848d 100644 --- a/src/calibre/gui2/tweak_book/editor/smarts/html.py +++ b/src/calibre/gui2/tweak_book/editor/smarts/html.py @@ -36,6 +36,11 @@ class Tag(object): self.name = tag self.self_closing = self_closing + def __repr__(self): + return '<%s start_block=%s start_offset=%s end_block=%s end_offset=%s self_closing=%s>' % ( + self.name, self.start_block.blockNumber(), self.start_offset, self.end_block.blockNumber(), self.end_offset, self.self_closing) + __str__ = __repr__ + def next_tag_boundary(block, offset, forward=True): while block.isValid(): ud = block.userData()