本文整理匯總了Python中sgml.HTMLParser.HTMLParser.do_hr方法的典型用法代碼示例。如果您正苦於以下問題:Python HTMLParser.do_hr方法的具體用法?Python HTMLParser.do_hr怎麽用?Python HTMLParser.do_hr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sgml.HTMLParser.HTMLParser
的用法示例。
在下文中一共展示了HTMLParser.do_hr方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: do_hr
# 需要導入模塊: from sgml.HTMLParser import HTMLParser [as 別名]
# 或者: from sgml.HTMLParser.HTMLParser import do_hr [as 別名]
def do_hr(self, attrs):
if attrs.has_key('src') and self.app.load_images:
align = extract_keyword('align', attrs, default='center',
conv=lambda s,gu=grailutil: gu.conv_enumeration(
gu.conv_normstring(s), ['left', 'center', 'right']))
self.implied_end_p()
self.formatter.push_alignment(align)
self.do_img({'border': '0', 'src': attrs['src']})
self.formatter.pop_alignment()
self.formatter.add_line_break()
return
HTMLParser.do_hr(self, attrs)
color = extract_keyword('color', attrs)
rule = self.viewer.rules[-1]
if attrs.has_key('noshade') and self.viewer.rules:
if color:
if not self.configcolor('background', color, widget=rule):
self.configcolor('background',
self.viewer.text['foreground'],
widget=rule)
else:
# this color is known to work already
rule.config(background=self.viewer.text['foreground'])
rule.config(relief=FLAT)
size = extract_keyword('size', attrs, 2,
conv=grailutil.conv_integer)
if size == 1:
# could not actually set it to 1 unless it was flat; do it now:
width = string.atoi(rule.cget('width'))
rule.config(borderwidth=0, height=1, width=width+2)
elif color:
self.configcolor('background', color, widget=rule)