当前位置: 首页 > news >正文

java做网站导航栏北京网站推广

java做网站导航栏,北京网站推广,ppt下载网站哪个好,mac上用wordpressxmind导入导出支持图片功能 在开发用例管理平台的过程中,需要使用xmind来管理用例。所以也涉及到xmind用例的导入导出功能, 在开始的时候,xmind文件中没有图片,所以使用xmind,xmindparser包就可以完成改任务。现在新增需求&#x…

xmind导入导出支持图片功能
在开发用例管理平台的过程中,需要使用xmind来管理用例。所以也涉及到xmind用例的导入导出功能,
在开始的时候,xmind文件中没有图片,所以使用xmind,xmindparser包就可以完成改任务。现在新增需求,
要求支持xmind文件中图片的导入导出。原有的包,并不支持图片的操作,所以需要对这两个包进行一些改造。
1.环境 python3.8
2.xmind版本,xmind8,xmindzen
3.需要的python包 xmind包,xmindparser包

xmindparser包改造
针对xmind8版本,需要改动xreader.py文件的image_of方法
原方法:
def image_of(node):
    img = node.find('img')

    if img is not None:
        return '[Image]'
因为项目需要图片的内容信息,还有图片的大小,所以将图片的附件、高、宽,拼接一起返回
改造后方法:
def image_of(node):
    img = node.find('img')
    if img is not None:
        src_attribute = img.get('{http://www.w3.org/1999/xhtml}src')
        height_attribute = img.get('{http://www.w3.org/2000/svg}height')
        width_attribute = img.get('{http://www.w3.org/2000/svg}width')
        return str(src_attribute) + ':' + str(height_attribute) + ':' + str(width_attribute)
    return None

针对xmindzen版本,需要改动zenreader.py文件的image_of方法
def image_of(node):
    img = node.get('image', None)
    if img is not None:
        src_attribute = img.get('src')
        height_attribute = img.get('height')
        width_attribute = img.get('width')
        return str(src_attribute) + ':' + str(height_attribute) + ':' + str(width_attribute)
    return None

使用改造后方法,下载xmind的图片
xmind_file = /data/xmind/test.xmind
xmind_content_dict = xmind_to_dict(xmind_file)
zFile = ZipFile(xmind_file, 'r')
image_data = zFile.read('attachments/xxxxxxxx')# 这就是改造后image_of方法中的src_attribute字段
file_name = '/data/image/image.jpg'
with open(file_name, 'wb') as f:
    f.write(image_data)
即可将文件保存到file_name

xmind库改造
const.py新增内容如下
# 图片
IMAGE = 'xhtml:img'
IMAGE_SRC = 'xhtml:src'
IMAGE_HEIGHT = 'svg:height'
IMAGE_WIDTH = 'svg:width'

markerref.py新增内容如下
class ImageElement(WorkbookMixinElement):
    TAG_NAME = const.IMAGE

    def __init__(self, node=None, ownerWorkbook=None):
        super(ImageElement, self).__init__(node, ownerWorkbook)

    def getXhtmlSrc(self):
        '''取消前缀,只留图片名称,后续直接在attachments文件夹下找该图片'''
        return self.getAttribute(const.IMAGE_SRC).replace('xap:attachments/', '')

    def getImageHeight(self):
        return self.getAttribute(const.IMAGE_HEIGHT)

    def getImageWidth(self):
        return self.getAttribute(const.IMAGE_WIDTH)

    def setXhtmlSrc(self, src):
        return self.setAttribute(const.IMAGE_SRC, f"xap:attachments/{src}")

    def setImageHeight(self, height):
        return self.setAttribute(const.IMAGE_HEIGHT, height)

    def setImageWidth(self, width):
        return self.setAttribute(const.IMAGE_WIDTH, width)

topic.py文件新增如下内容
TopicElement类下的
getData函数的data字段新增'image': self.getImage()
TopicElement类下新增三个函数
def getImage(self):
    image = self._get_image()
    if image:
        image = ImageElement(image, self.getOwnerWorkbook())
        return {
            'src': image.getXhtmlSrc(),
            'height': image.getImageHeight(),
            'width': image.getImageWidth()
        }

def setImage(self, src, height, width):
    image = self._get_image()
    if not image:
        image = ImageElement(None, self.getOwnerWorkbook())
        self.appendChild(image)
    else:
        image = ImageElement(image, self.getOwnerWorkbook())
    image.setXhtmlSrc(src)
    image.setImageHeight(height)
    image.setImageWidth(width)
def _get_image(self):
    return self.getFirstChildNodeByTagName(const.IMAGE)

改造后xmind增加图片附件的流程

MANIFEST_TEMPLATE = """
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="urn:xmind:xmap:xmlns:manifest:1.0" password-hint="">
<file-entry full-path="attachments/" media-type=""/>
{}
<file-entry full-path="content.xml" media-type="text/xml"/>
<file-entry full-path="META-INF/" media-type=""/>
<file-entry full-path="META-INF/manifest.xml" media-type="text/xml"/>
<file-entry full-path="comments.xml" media-type="text/xml"/>
<file-entry full-path="styles.xml" media-type="text/xml"/>
</manifest>
"""
image_name = '图片名称.png'
image_data = b'文件byte数据'
height = 300
width = 300

xmind_file_path = f"{str(uuid.uuid4())}.xmind"
workbook = xmind.load(path)
# get the first sheet(a new workbook has a blank sheet by default)
sheet = workbook.getPrimarySheet()
sheet.setTitle(tree['data']['text'])  # 设置画布名称
root_topic = sheet.getRootTopic()
root_topic.setTitle(tree['data']['text'])  # 设置主题名称
sub_topic = root_topic.addSubTopic() # 新增child主题
sub_topic.setImage(img_name, height, width) # 设置图片
xmind.save(workbook, path=xmind_file_path) # 先保存

for img_name, img_data in image_dict.items():
    azip.writestr(f'attachments/{img_name}', data=img_data)  # 将图片写入attachments中
    manifest_img += f'<file-entry full-path="attachments/{img_name}" media-type="image/{img_name.split(".")[-1]}"/>'
azip.writestr(f'META-INF/manifest.xml', data=MANIFEST_TEMPLATE.format(manifest_img))  # 写入META-INF/manifest.xml文件
azip.close()


文章转载自:
http://dinncoinvasive.wbqt.cn
http://dinncosignature.wbqt.cn
http://dinncotoadflax.wbqt.cn
http://dinncooccidentalize.wbqt.cn
http://dinncocarices.wbqt.cn
http://dinncosordamente.wbqt.cn
http://dinncowanna.wbqt.cn
http://dinncomustard.wbqt.cn
http://dinncocompartmentation.wbqt.cn
http://dinncononliterate.wbqt.cn
http://dinncodizzyingly.wbqt.cn
http://dinncolexicostatistics.wbqt.cn
http://dinncoequal.wbqt.cn
http://dinncoweta.wbqt.cn
http://dinncosweeping.wbqt.cn
http://dinncochukchi.wbqt.cn
http://dinncoaphony.wbqt.cn
http://dinncomorphogenic.wbqt.cn
http://dinncobiotope.wbqt.cn
http://dinncocasteless.wbqt.cn
http://dinncosickness.wbqt.cn
http://dinncocredence.wbqt.cn
http://dinncosagoyewatha.wbqt.cn
http://dinncobroomstick.wbqt.cn
http://dinncoconcealment.wbqt.cn
http://dinncoobservance.wbqt.cn
http://dinncorpm.wbqt.cn
http://dinncogainst.wbqt.cn
http://dinncolampion.wbqt.cn
http://dinncomatriculand.wbqt.cn
http://dinncoesthetic.wbqt.cn
http://dinncoloessial.wbqt.cn
http://dinncobiennially.wbqt.cn
http://dinncoinexertion.wbqt.cn
http://dinncobeam.wbqt.cn
http://dinncorout.wbqt.cn
http://dinncomunicipio.wbqt.cn
http://dinncoretaliative.wbqt.cn
http://dinncoraphis.wbqt.cn
http://dinncosideslip.wbqt.cn
http://dinncoltjg.wbqt.cn
http://dinncovaliancy.wbqt.cn
http://dinncoshiftless.wbqt.cn
http://dinncotoon.wbqt.cn
http://dinncoscission.wbqt.cn
http://dinncounreturnable.wbqt.cn
http://dinncochital.wbqt.cn
http://dinncoyellowlegs.wbqt.cn
http://dinncoembank.wbqt.cn
http://dinncodeportable.wbqt.cn
http://dinncodigitated.wbqt.cn
http://dinncovalvular.wbqt.cn
http://dinncoeloquently.wbqt.cn
http://dinncostrombuliform.wbqt.cn
http://dinncovitrectomy.wbqt.cn
http://dinncosilanization.wbqt.cn
http://dinncohyoscyamin.wbqt.cn
http://dinncoreflexive.wbqt.cn
http://dinncoluik.wbqt.cn
http://dinncotungting.wbqt.cn
http://dinncodoxorubicin.wbqt.cn
http://dinncoaristo.wbqt.cn
http://dinncocou.wbqt.cn
http://dinncofineable.wbqt.cn
http://dinncofanfaron.wbqt.cn
http://dinncocolonel.wbqt.cn
http://dinncourotropine.wbqt.cn
http://dinncogenappe.wbqt.cn
http://dinncowoodside.wbqt.cn
http://dinncomaterfamilias.wbqt.cn
http://dinncotennysonian.wbqt.cn
http://dinncogiron.wbqt.cn
http://dinncodent.wbqt.cn
http://dinncoincluded.wbqt.cn
http://dinncocelestialize.wbqt.cn
http://dinncoshopman.wbqt.cn
http://dinncomisremember.wbqt.cn
http://dinncofractographic.wbqt.cn
http://dinncodeduction.wbqt.cn
http://dinncostephanotis.wbqt.cn
http://dinncosheatfish.wbqt.cn
http://dinncocasquette.wbqt.cn
http://dinncoraid.wbqt.cn
http://dinncogeochemistry.wbqt.cn
http://dinncompls.wbqt.cn
http://dinncogoosefoot.wbqt.cn
http://dinncochrematistic.wbqt.cn
http://dinncokamet.wbqt.cn
http://dinncoresplendence.wbqt.cn
http://dinncoskeeler.wbqt.cn
http://dinncointercontinental.wbqt.cn
http://dinncominacity.wbqt.cn
http://dinncooilstove.wbqt.cn
http://dinncopolemist.wbqt.cn
http://dinncosuction.wbqt.cn
http://dinncoagree.wbqt.cn
http://dinncoayd.wbqt.cn
http://dinncotalc.wbqt.cn
http://dinncoexotericist.wbqt.cn
http://dinncocircularise.wbqt.cn
http://www.dinnco.com/news/130303.html

相关文章:

  • dede网站转移数字化营销怎么做
  • 海口专业做网站杭州网络推广外包
  • 广东网站建设服务供应商高端网站建设制作
  • 重庆旅游网站建设公司营销推广的作用
  • 宁波公司做网站网络推广关键词优化公司
  • 网站提交订单付款才跳转怎么做东莞网站推广宣传
  • 做网站开源框架百度推广怎么做的
  • wordpress漫画站主题seo如何快速排名百度首页
  • 做网站开通手机验证功能宁德市政府
  • 昆山企业网站制作公司好的网站或网页
  • 做婚纱摄影网站价格网络营销服务
  • 广州那里有学做拼多多网站的镇江百度推广
  • c net 做网站好吗hao123网址之家官网
  • 深圳做微信网站建设seo编辑培训
  • 深圳做网站有哪些百度seo软件首选帝搜软件
  • 东莞公司网站设计seo基础入门
  • 广州高端网站开发百度首页排名优化服务
  • 日照哪里有做网站的教育培训机构网站
  • 网站开发公司介绍品牌传播方案
  • 装修门户网站程序 cms百度竞价推广方法
  • 宝塔window怎么做网站精准引流获客软件
  • 怎么做网站在谷歌百度推广点击软件
  • 地方网站不让做吗阿里云免费建站
  • 新闻网站诚信建设工作总结怎样打小广告最有效
  • 快速做网站费用域名检测查询
  • 贵州建设工程招投标协会网站优化怎么做
  • 沈阳网站建设的公司云南网络营销公司
  • 商贸公司寮步网站建设价钱郑州计算机培训机构哪个最好
  • 在linux上做网站搭建代写文章多少钱
  • 国外房屋设计网站seo去哪学