From 3e718aa4d6df451e5d55964a31f5d91bd2464ad1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 Mar 2013 14:44:27 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/oeb/polish/toc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/calibre/ebooks/oeb/polish/toc.py b/src/calibre/ebooks/oeb/polish/toc.py index 7168e4c7ac..d5b013fb72 100644 --- a/src/calibre/ebooks/oeb/polish/toc.py +++ b/src/calibre/ebooks/oeb/polish/toc.py @@ -57,6 +57,16 @@ class TOC(object): except ValueError: return 1 + def get_lines(self, lvl=0): + frag = ('#'+self.frag) if self.frag else '' + ans = [(u'\t'*lvl) + u'TOC: %s --> %s%s'%(self.title, self.dest, frag)] + for child in self: + ans.extend(child.get_lines(lvl+1)) + return ans + + def __str__(self): + return b'\n'.join([x.encode('utf-8') for x in self.get_lines()]) + def child_xpath(tag, name): return tag.xpath('./*[calibre:lower-case(local-name()) = "%s"]'%name)