# -*- coding: utf-8 -*-
# XMIND文件转为excel工具
# Form implementation generated from reading ui file 'xmind_to_excel.ui'
#
# Created by: tianmaojin
#
# WARNING! All changes made in this file will be lost!
import os
import sys
import xlwt
from xmindparser import xmind_to_dict
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Xmind_Convert(object):
"""
基本方法类
"""
def __init__(self):
self.LOG = ' '
def resolvePath(self, dict_info, lists, title):
# title去除首尾空格
title = title.strip()
# 如果title是空字符串,则直接获取value
if len(title) == 0:
concatTitle = dict_info['title'].strip()
else:
concatTitle = title + '\t' + dict_info['title'].strip()
if not dict_info.__contains__('topics'):
lists.append(concatTitle)
else:
for d in dict_info['topics']:
self.resolvePath(d, lists, concatTitle)
def xmind_parse(self, list_info, excelname):
f = xlwt.Workbook()
# 生成excel文件,单sheet,sheet名为:sheet1
sheet = f.add_sheet(u'测试点', cell_overwrite_ok=True)
row0 = [u'序号', u'模块', u'测试点']
# 生成第一行中固定表头内容
for i in range(0, len(row0)):
sheet.write(0, i, row0[i])
# 增量索引
index = 0