本文整理汇总了Python中pyaid.string.StringUtils.StringUtils.htmlEscape方法的典型用法代码示例。如果您正苦于以下问题:Python StringUtils.htmlEscape方法的具体用法?Python StringUtils.htmlEscape怎么用?Python StringUtils.htmlEscape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.string.StringUtils.StringUtils
的用法示例。
在下文中一共展示了StringUtils.htmlEscape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: autoDescription
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import htmlEscape [as 别名]
def autoDescription(self):
if self._autoDescription:
return self._autoDescription
if not self._result:
return u''
source = self._result
p = re.compile('<script.*(?!</script>)', re.DOTALL)
source = p.sub(u'', source)
p = re.compile('<pre.*(?!</pre>)', re.DOTALL)
source = p.sub(u'', source)
p = re.compile('<[/A-Za-z]+[^>]+>')
source = p.sub(u'\n', source)
res = re.compile('[A-Za-z0-9.,?!\'" -:;\(\)&%$#@]{64,}').search(source)
if not res or not res.group():
return u''
r = res.group()
r = r[:2000].replace(u'\n',u' ')
r = MarkupProcessor._WHITESPACE_KILLER_REGEX.sub(u' ', r)
return StringUtils.htmlEscape(StringUtils.getCompleteFragment(r, 255, True))
示例2: add
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import htmlEscape [as 别名]
def add(self, s, traceStack =False, shaveStackTrace =0, request =None, htmlEscape =False):
"""Prints s to standard output and a log file."""
s = Logger._formatAsString(s)
if traceStack:
s += '\nStack Trace:\n' + Logger.getFormattedStackTrace(shaveStackTrace)
if self._htmlEscape or htmlEscape:
s = StringUtils.htmlEscape(s)
if self._traceLogs:
out = self._asASCII(s)
print out
for cb in self._printCallbacks:
try:
cb(self, out)
except Exception, err:
pass
示例3: createLogMessage
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import htmlEscape [as 别名]
def createLogMessage(
cls, logValue, traceStack, shaveStackTrace, htmlEscape, prefix =None, **kwargs
):
""" Formats log message data into a string for output """
doIndent = kwargs.get('indent', True)
if doIndent:
logValue = cls.formatAsString(logValue)
elif isinstance(logValue, (list, tuple)):
logValue = '\n'.join(logValue)
if htmlEscape:
logValue = StringUtils.htmlEscape(logValue)
if doIndent:
logValue = logValue.replace('\n', '\n ')
logValue = StringUtils.strToUnicode(logValue)
if not StringUtils.isStringType(logValue):
logValue = 'FAILED TO LOG RESPONSE'
out = {'log':logValue}
if prefix:
logPrefix = StringUtils.strToUnicode(prefix)
if not StringUtils.isStringType(logPrefix):
logPrefix = 'FAILED TO CREATE PREFIX'
out['prefix'] = logPrefix
if traceStack:
logStack = StringUtils.strToUnicode(
'Stack Trace:\n' + cls.getFormattedStackTrace(shaveStackTrace))
if not StringUtils.isStringType(logStack):
logStack = 'FAILED TO CREATE STACK'
out['stack'] = logStack
return out