本文整理汇总了Python中src.tools.match.Match.html_body方法的典型用法代码示例。如果您正苦于以下问题:Python Match.html_body方法的具体用法?Python Match.html_body怎么用?Python Match.html_body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.tools.match.Match
的用法示例。
在下文中一共展示了Match.html_body方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_single_html_book
# 需要导入模块: from src.tools.match import Match [as 别名]
# 或者: from src.tools.match.Match import html_body [as 别名]
def create_single_html_book(self, book_package):
title = book_package.get_title()
if not title:
# 电子书题目为空时自动跳过
# 否则会发生『rm -rf / 』的惨剧
return
Path.reset_path()
Path.chdir(Path.result_path)
Path.rmdir(u'./' + title)
Path.mkdir(u'./' + title)
Path.chdir(u'./' + title)
page = []
for book in book_package.book_list:
page += book.page_list
content = u' \r\n '.join([Match.html_body(x.content) for x in page]).replace(u'../images/', u'./images/')
with open(TemplateConfig.content_base_uri) as html:
content = html.read().format(title=title, body=content).replace(u'../style/', u'./')
with open(title + u'.html', 'w') as html:
html.write(content)
Path.copy(Path.html_pool_path + u'/../{}/OEBPS/images'.format(title), u'./images')
Path.copy(Path.www_css + u'/customer.css', u'./customer.css')
Path.copy(Path.www_css + u'/markdown.css', u'./markdown.css')
Path.copy(Path.www_css + u'/normalize.css', u'./normalize.css')
Path.reset_path()
return
示例2: create_single_html_book
# 需要导入模块: from src.tools.match import Match [as 别名]
# 或者: from src.tools.match.Match import html_body [as 别名]
def create_single_html_book(self):
title = '_'.join([book.epub.title for book in self.book_list])
title = title.strip()[:128] # 避开window文件名长度限制
title = ExtraTools.fix_filename(title) # 移除特殊字符
Path.reset_path()
Path.chdir(Path.result_path)
Path.rmdir(u'./' + title)
Path.mkdir(u'./' + title)
Path.chdir(u'./' + title)
page = []
for book in self.book_list:
page += book.page_list
content = ' \r\n<hr /> \r\n '.join([Match.html_body(x.content) for x in page]).replace('../images/', './images/')
with open(Path.base_path + '/src/template/content/single_html.html') as html:
template = html.read().format(title=title, content=content)
with open(title + u'.html', 'w') as html:
html.write(template)
shutil.copytree(Path.html_pool_path + u'/../{}/OEBPS/images'.format(title), './images')
shutil.copy(Path.www_css + '/front.css' , './front.css')
shutil.copy(Path.www_css + '/markdown.css' , './markdown.css')
Path.reset_path()
return