提交 73adf828 创建 作者: shx's avatar shx

init

上级
#python3
import odf
import sys
import requests, json
from odf.namespaces import TEXTNS
from odf.element import Element
from odf.opendocument import load
from odf import text,meta,office,draw
# 加载报告文件
doc=load(sys.argv[1])
# API路径
api_url = sys.argv[2] + "/api/v4/labreportstatistics?" + sys.argv[4] + "=" + sys.argv[5]
# 项目id
project_id = sys.argv[3]
# ci_job_token
token = sys.argv[4]
# 将需要的报告统计参数保存
for stat in doc.getElementsByType(meta.DocumentStatistic):
# 取得报告页数、字数、表格数、图片数信息
page_count = stat.getAttribute('pagecount')
word_count = stat.getAttribute('wordcount')
table_count = stat.getAttribute('tablecount')
image_count = stat.getAttribute('imagecount')
# 还可以统计出报告中的以下内容
# stat.getAttribute('cellcount')
# 汉字或字符数量(含空格)stat.getAttribute('charactercount')
# stat.getAttribute('drawcount')
# stat.getAttribute('framecount')
# 汉字或字符数量(不含空格)stat.getAttribute('nonwhitespacecharactercount')
# stat.getAttribute('objectcount')
# 链接数量stat.getAttribute('oleobjectcount')
# 段落数量stat.getAttribute('paragraphcount')
# stat.getAttribute('rowcount')
# 句子数量stat.getAttribute('sentencecount')
# stat.getAttribute('syllablecount')
# 准备向接口发送的参数
data = {
'project_id': project_id,
'page_count':page_count,
'word_count':word_count,
'table_count':table_count,
'image_count':image_count
}
# 访问api
r = requests.post(api_url, data)
# 输出接口返回信息
print(r.json())
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论