xmind2Excel 1.0.1 xmind2testcase 1.5.0 xxmind 1.0.1
Python -c "from xmind2Excel.main import Main; Main()"
代码实现解析xmind:
import xmindparser import pandas as pd import numpy as np def xmind_constructor(filePath=None): xmindparser.config = { 'showTopicId': True, # 是否展示主题ID 'hideEmptyValue': True # 是否隐藏空值 } filePath = '/Users/chenquan/Documents/tapd01.xmind' content = xmindparser.xmind_to_dict(filePath) root_topics = content[0]["topic"]['topics'] root_title = content[0]["topic"]['title'] # print(root_title) testcases = [] for i in range(len(root_topics)): module_title = root_topics[i]['title'] module_topics = root_topics[i]['topics'] print(module_title) for j in range(len(module_topics)): second_moudle_title = module_topics[j]['title'] second_name_topics = module_topics[j].get("topics") if second_name_topics: # print(module_title+"--"+name_title) for k in range(len(second_name_topics)): name_title = second_name_topics[k]['title'] name_topics = second_name_topics[k].get("topics") if name_topics: # print(module_title+"--"+name_title+"--"+precondtion_title) for m in range(len(name_topics)): precondition_title = name_topics[m]['title'] precondition_topics = name_topics[m].get("topics",'') if precondition_topics: for n in range(len(precondition_topics)): step_title = precondition_topics[n]['title'] step_topics = precondition_topics[n].get("topics") if step_topics: for x in range(len(step_topics)): expect_title = step_topics[x].get('title','') testcases.append([root_title+""+module_title+second_moudle_title+name_title ,precondition_title,step_title,expect_title]) return testcases if __name__ == '__main__': rs = xmind_constructor() data =np.array(rs) df = pd.DataFrame(data,columns=['title','precondition','step','expect']) df.to_csv("./test1.csv")