本文整理汇总了Python中utils.bodyfinder函数的典型用法代码示例。如果您正苦于以下问题:Python bodyfinder函数的具体用法?Python bodyfinder怎么用?Python bodyfinder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bodyfinder函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setFormat
def setFormat(self, format):
""" Set text format and Dublin Core resource format.
"""
value = str(format)
old_value = self.text_format
if value == 'text/html' or value == 'html':
self.text_format = 'html'
elif value == 'text/plain':
if self.text_format not in ('structured-text', 'plain'):
self.text_format = 'structured-text'
elif value == 'plain':
self.text_format = 'plain'
else:
self.text_format = 'structured-text'
# Did the format change? We might need to re-cook the content.
if value != old_value:
if html_headcheck(self.text) and value != 'plain':
self.text = bodyfinder(self.text)
self._edit( self.text
, text_format=self.text_format
, safety_belt=self._safety_belt
)
开发者ID:goschtl,项目名称:zope,代码行数:25,代码来源:Document.py
示例2: edit
def edit(self, text_format, text, file='', safety_belt=''):
""" Update the document.
To add webDav support, we need to check if the content is locked, and if
so return ResourceLockedError if not, call _edit.
Note that this method expects to be called from a web form, and so
disables header processing
"""
self.failIfLocked()
if not self._safety_belt_update(safety_belt=safety_belt):
msg = _(u'Intervening changes from elsewhere detected. '
u'Please refetch the document and reapply your changes. '
u'(You may be able to recover your version using the '
u"browser 'back' button, but will have to apply them to "
u'a freshly fetched copy.)')
raise EditingConflict(msg)
if file and (type(file) is not type('')):
contents=file.read()
if contents:
text = contents
if html_headcheck(text) and text_format.lower() != 'plain':
text = bodyfinder(text)
self.setFormat(text_format)
self._edit(text)
self.reindexObject()
开发者ID:goschtl,项目名称:zope,代码行数:26,代码来源:Document.py
示例3: handleText
def handleText(self, text, format=None, stx_level=None):
""" Handles the raw text, returning headers, body, format """
headers = {}
if not format:
format = self.guessFormat(text)
if format == 'html':
parser = SimpleHTMLParser()
parser.feed(text)
headers.update(parser.metatags)
if parser.title:
headers['Title'] = parser.title
body = bodyfinder(text)
else:
headers, body = parseHeadersBody(text, headers)
if stx_level:
self._stx_level = stx_level
return headers, body, format
开发者ID:goschtl,项目名称:zope,代码行数:17,代码来源:Document.py
示例4: edit
def edit(self, text_format, text, file='', safety_belt=''):
""" Update the document.
To add webDav support, we need to check if the content is locked, and if
so return ResourceLockedError if not, call _edit.
Note that this method expects to be called from a web form, and so
disables header processing
"""
self.failIfLocked()
if file and (type(file) is not type('')):
contents=file.read()
if contents:
text = contents
if html_headcheck(text) and text_format.lower() != 'plain':
text = bodyfinder(text)
self.setFormat(text_format)
self._edit(text=text, text_format=text_format, safety_belt=safety_belt)
self.reindexObject()
开发者ID:goschtl,项目名称:zope,代码行数:19,代码来源:Document.py
示例5: edit
def edit( self
, text_format
, text
, file=''
, safety_belt=''
):
"""
*used to be WorkflowAction(_edit)
To add webDav support, we need to check if the content is locked, and if
so return ResourceLockedError if not, call _edit.
Note that this method expects to be called from a web form, and so
disables header processing
"""
self.failIfLocked()
if file and (type(file) is not type('')):
contents=file.read()
if contents:
text = self.text = contents
text = bodyfinder(text)
self.setFormat(value=text_format)
self._edit(text=text, text_format=text_format, safety_belt=safety_belt)
self.reindexObject()
开发者ID:goschtl,项目名称:zope,代码行数:23,代码来源:Document.py
注:本文中的utils.bodyfinder函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论