本文整理汇总了Python中markupsafe.Markup.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python Markup.__new__方法的具体用法?Python Markup.__new__怎么用?Python Markup.__new__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类markupsafe.Markup
的用法示例。
在下文中一共展示了Markup.__new__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __new__
# 需要导入模块: from markupsafe import Markup [as 别名]
# 或者: from markupsafe.Markup import __new__ [as 别名]
def __new__(cls, content=u'', preformatted=None):
obj = Markup.__new__(cls, content)
if preformatted is None:
tmp = content.lower()
obj._preformatted = not any(tag in tmp for tag in (u'<p>', u'<p ', u'<br', u'<li>'))
else:
obj._preformatted = preformatted
return obj
示例2: __new__
# 需要导入模块: from markupsafe import Markup [as 别名]
# 或者: from markupsafe.Markup import __new__ [as 别名]
def __new__(cls, content=u"", preformatted=None):
obj = Markup.__new__(cls, content)
if preformatted is None:
tmp = content.lower()
obj._preformatted = not any(tag in tmp for tag in (u"<p>", u"<p ", u"<br", u"<li>"))
else:
obj._preformatted = preformatted
return obj
示例3: __new__
# 需要导入模块: from markupsafe import Markup [as 别名]
# 或者: from markupsafe.Markup import __new__ [as 别名]
def __new__(cls, base=u'', encoding=None, errors='strict'):
"""Add encoding for base of type str."""
if encoding is None and isinstance(base, str):
encoding = 'utf8'
warnings.warn(
"Convert string '{0}' in template to unicode.".format(base),
RuntimeWarning, stacklevel=3)
return jinja2_Markup.__new__(cls, base=base, encoding=encoding,
errors=errors)
示例4: __new__
# 需要导入模块: from markupsafe import Markup [as 别名]
# 或者: from markupsafe.Markup import __new__ [as 别名]
def __new__(cls, base=u'', encoding=None, errors='strict'):
if encoding is None and isinstance(base, str):
encoding = 'utf8'
return jinja2_Markup.__new__(cls, base=base, encoding=encoding,
errors=errors)