1 Star 0 Fork 1

paydy/read-becs-report

forked from iaso2h/read-becs-report 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
erase_cover.py 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
iaso2h 提交于 2020-05-20 00:22 . Code refactoring
import global_control
import logging
logger = logging.getLogger(name=__name__)
def erase(file_type, docx, end_p_index):
paras = docx.paragraphs
tables = docx.tables
sections = docx.sections
# 去除页眉
if global_control.settings[file_type]["去除斯维尔原页眉"] is True:
logger.info("Erasing header")
for sec in sections:
sec.header.is_linked_to_previous = True
else:
pass
def delete_element(el):
el._element.getparent().remove(el._element)
# 去除封面和目录
if global_control.settings[file_type]["去除斯维尔原封面"] is True:
logger.info(f"Erasing cover in {file_type}")
for table in tables[:2]:
delete_element(table)
if global_control.settings[file_type]["去除斯维尔原目录"] is True:
logger.info("Erasing table of content")
p_key = 0
for p_index, p in enumerate(paras):
if p.text == "建筑概况":
p_key = p_index
break
for el in paras[:p_key]:
delete_element(el)
for el in paras[:end_p_index]:
delete_element(el)
else:
pass
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/paydy/read-becs-report.git
git@gitee.com:paydy/read-becs-report.git
paydy
read-becs-report
read-becs-report
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385