mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 02:13:47 +02:00
DRYer
This commit is contained in:
parent
976a3f9b4a
commit
2a2a08b660
1 changed files with 3 additions and 7 deletions
|
|
@ -396,12 +396,8 @@ def xml2str(root, pretty_print=False, strip_comments=False, with_tail=True):
|
|||
return ans
|
||||
|
||||
|
||||
def xml2unicode(root, pretty_print=False):
|
||||
return etree.tostring(root, pretty_print=pretty_print)
|
||||
|
||||
|
||||
def xml2text(elem):
|
||||
return etree.tostring(elem, method='text', encoding=unicode_type, with_tail=False)
|
||||
def xml2text(elem, pretty_print=False):
|
||||
return etree.tostring(elem, method='text', encoding=unicode_type, with_tail=False, pretty_print=pretty_print)
|
||||
|
||||
|
||||
def escape_cdata(root):
|
||||
|
|
@ -1088,7 +1084,7 @@ def loader2(*args):
|
|||
def unicode_representation(self):
|
||||
data = self.data
|
||||
if isinstance(data, etree._Element):
|
||||
return xml2unicode(data, pretty_print=self.oeb.pretty_print)
|
||||
return xml2text(data, pretty_print=self.oeb.pretty_print)
|
||||
if isinstance(data, unicode_type):
|
||||
return data
|
||||
if hasattr(data, 'cssText'):
|
||||
|
|
|
|||
Loading…
Reference in a new issue