Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
xml = ( u'%s'
% (url_id, xml) )
self.xml += xml
def __unicode__(self):
return self.xml
def __str__(self):
return self.xml
def __html__(self):
return self.xml
R = RichText
class Listing(object):
r"""class to manage \n and \a without to use RichText,
by this way you keep the current template styling
use {{ mylisting }} in your template and
context={ mylisting:Listing(the_listing_with_newlines) }
"""
def __init__(self, text):
# If not a string : cast to string (ex: int, dict etc...)
if not isinstance(text, (six.text_type, six.binary_type)):
text = six.text_type(text)
self.xml = (escape(text)
.replace('\n', NEWLINE_XML)
.replace('\a', NEWPARAGRAPH_XML)
def add(self, text, style=None,
color=None,
highlight=None,
size=None,
subscript=None,
superscript=None,
bold=False,
italic=False,
underline=False,
strike=False,
font=None,
url_id=None):
# If a RichText is added
if isinstance(text, RichText):
self.xml += text.xml
return
# If not a string : cast to string (ex: int, dict etc...)
if not isinstance(text, (six.text_type, six.binary_type)):
text = six.text_type(text)
if not isinstance(text, six.text_type):
text = text.decode('utf-8',errors='ignore')
text = (escape(text)
.replace('\n', NEWLINE_XML)
.replace('\a', NEWPARAGRAPH_XML)
.replace('\t', TAB_XML)
.replace('\f', PAGE_BREAK))
prop = u''