def createMindmap(list): OUTPUT = "test.xmind" file_name = "SQL Test" parents = list[0] children = list[1] distingushParentList = removeDupilicates(parents) xmind = XMindDocument.create(file_name, file_name) first_sheet = xmind.get_first_sheet() root_topic = first_sheet.get_root_topic() constructTreeMap(root_topic, parents, children, distingushParentList) #set all distingush parent nodes at same level #for index, function in enumerate(parent, start=0): # default is zero # if index == 0: # parent_node = root_topic.add_subtopic(function) # child_node = parent_node.add_subtopic(child[child_index]) # child_index += 1 # else: # if parent[index] == parent[index-1]: # parent_node.add_subtopic(child[child_index]) # child_index += 1 # else: # parent_node = root_topic.add_subtopic(function) # child_node = parent_node.add_subtopic(child[child_index]) # child_index += 1 xmind.save(OUTPUT) print("Saved to", OUTPUT)
def generate_simple(): doc = XMindDocument.create(u"root_topic_name", u"Projekty") sheet = doc.get_first_sheet() root = sheet.get_root_topic() root.set_note("View the Help sheet for info\nwhat you can do with this map") # (file = "", doc = "", shape = , line_color = "", line_width = "1pt" ) #SHAPE_RECTANGLE #SHAPE_ROUND_RECTANGLE #SHAPE_ELLIPSIS style = doc.create_topic_style(fill = "#37D02B") #style_sub = doc.create_topic_style(fill = "CCCCCC") for i in range(1,5): topic = root.add_subtopic(u"Elemiątko %d" % i, "b%d" % i) topic.set_label("%d" % i) topic.set_style(style) topic.add_subtopic(u"Załączony").set_attachment( file("map_creator.py").read(), ".txt") topic.set_link("file:/home/wondereamer/3.png") for j in range(1,3): subtopic = topic.add_subtopic(u"Subelemiątko %d/%d" % (i,j), u"a%da%d" % (i,j)) subtopic.add_marker("task-start") if j < 2: subtopic.add_marker("other-people") legend = sheet.get_legend() legend.add_marker("task-start", u"Dzień dobry") legend.add_marker("other-people", u"Do widzenia") return doc
sublineEnd=0 sublines=[] breakLines=[[m.start(0),m.end(0)] for m in p.finditer(line)] for breakLine in breakLines: replace="" if(len(line)-m.end(0)>2): replace=" (ref) " listOfSublines[l]=line[breakLine[0]+1:breakLine[1]-1].split("; ") line=line.replace(line[breakLine[0]:breakLine[1]],replace) listOflines.append(line) return listOflines,listOfSublines #options -start maxLength=80 xmind = XMindDocument.create("sheet1","article") information="52r5pnqlh67gsj8d1v0469s1fm" ref="1t2ehckaq1o9cnnnb0ru8k5a53" xmind.embed_markers("PackageCompiler.xmp") style_plan=XMindDocument.create_topic_style(xmind,'#80FF80',"org.xmind.topicShape.rectangle","#CACACA",line_width = "2pt") style_text=XMindDocument.create_topic_style(xmind,'#CEFFCE',"org.xmind.topicShape.rectangle","#CACACA",line_width = "1pt") style_ref=XMindDocument.create_topic_style(xmind,'#E5E5E5',"org.xmind.topicShape.roundedRect","#CACACA",line_width = "1pt") style_root=XMindDocument.create_topic_style(xmind,'#37D02B',"org.xmind.topicShape.roundedRect","#CACACA",line_width = "3pt") p = re.compile('(' +'\(' +'[^\d)]' +'[^\)]*?' +'\d\d\d\d' +'.*?' +'\)' +')')
def convert2xmind(self, xmindfile=""): """ - Read from the text file and convert of list of string tokens - Read the string tokens and parse it - Create Abstract tree with all nodes. - Convert nodes to mindmap nodes """ # read the text contents lstr = re.split(r"\n", self.fstr.strip()) whitespace = re.compile(r"^\s+") node = [[]] level = 0 OUTPUT = "" dprint(lstr) for tagstr in lstr: if not tagstr: continue if re.match("^\s*$", tagstr): continue if re.match("^\s*[\#]\s*", tagstr): continue match = whitespace.search(tagstr) if not match: level = 0 if len(node) > 2: xmind.save(OUTPUT) print("Saved to", os.path.join(os.getcwd(), OUTPUT)) if OUTPUT: OUTPUT = "" node = [[]] else: level = int(len(match.group()) / 4) last = level - 1 if not node[level]: node.append([]) self.attr = self.get_xmind_attr(tagstr) tagstr = self.attr["topic"] notestr = self.attr["note"] lnkstr = self.attr["link"] if tagstr: dprint(tagstr) if notestr: dprint("::", notestr) if lnkstr: dprint("!", lnkstr) if level == 0: OUTPUT = tagstr + ".xmind" OUTPUT.strip() xmind = XMindDocument.create(tagstr, tagstr) first_sheet = xmind.get_first_sheet() topic = first_sheet.get_root_topic() subtopic = topic topicstyle = xmind.create_topic_style(fill=colors[level]) subtopic.set_style(topicstyle) elif node[last]: topic = node[last][len(node[last]) - 1][0] subtopic = topic.add_subtopic(self.attr["topic"]) if notestr: subtopic.set_note(notestr) if lnkstr: subtopic.set_link(lnkstr) if level < len(colors) and level == 1: topicstyle = xmind.create_topic_style(fill=colors[level]) # shape="SHAPE_ROUND_RECTANGLE") subtopic.set_style(topicstyle) node[level].append([subtopic]) dprint(level, ":", node[level]) if (level > 0) and node[last]: node[last][len(node[last]) - 1].append([len(node[level]) - 1]) dprint("prev:", node[last]) dprint("-" * 60) dprint(len(node), range(len(node) - 1)) dprint(node) dprint("-----") for start_index in range(len(node) - 2): dprint("len ==>", range(len(node[start_index]))) for next_index in range(len(node[start_index])): dprint(start_index, "==>", node[start_index][next_index][0]) for elem in range(1, len(node[start_index][next_index])): dprint("@:", node[start_index][next_index][elem][0]) dprint("@@@:", node[start_index + 1][node[start_index][next_index][elem][0]][0]) if len(node) > 1: xmind.save(OUTPUT) print("Saved to", os.path.join(os.getcwd(), OUTPUT)) if debug: xmind.pretty_print()
def __init__(self, root_name): self.doc = XMindDocument.create(u"first sheet name", root_name) self.sheet = self.doc.get_first_sheet() self.root = self.sheet.get_root_topic()
def convert2xmind(self, xmindfile=''): """ - Read from the text file and convert of list of string tokens - Read the string tokens and parse it - Create Abstract tree with all nodes. - Convert nodes to mindmap nodes """ # read the text contents lstr=re.split(r'\n', self.fstr.strip()) whitespace=re.compile(r'^\s+') node=[[]] level = 0 OUTPUT = "" dprint(lstr) for tagstr in lstr: if not tagstr: continue if (re.match('^\s*$',tagstr)) : continue if (re.match('^\s*[\#]\s*',tagstr)): continue match=whitespace.search(tagstr) if not match: level=0 if (len(node) > 2): xmind.save(OUTPUT) print("Saved to", os.path.join(os.getcwd(),OUTPUT)) if (OUTPUT): OUTPUT="" node=[[]] else: level = int(len(match.group()) / 4) last = level-1 if not node[level]: node.append([]) self.attr=self.get_xmind_attr(tagstr) tagstr = self.attr["topic"] notestr = self.attr["note"] lnkstr = self.attr["link"] if tagstr: dprint(tagstr) if notestr: dprint("::",notestr) if lnkstr: dprint("!", lnkstr) if (level == 0): OUTPUT = tagstr+".xmind" OUTPUT.strip() xmind = XMindDocument.create(tagstr, tagstr) first_sheet = xmind.get_first_sheet() topic = first_sheet.get_root_topic() subtopic = topic topicstyle = xmind.create_topic_style(fill=colors[level]) subtopic.set_style(topicstyle) elif node[last]: topic = node[last][len(node[last])-1][0] subtopic = topic.add_subtopic(self.attr["topic"]) if notestr: subtopic.set_note(notestr) if lnkstr : subtopic.set_link(lnkstr) if level < len(colors) and level == 1: topicstyle = xmind.create_topic_style(fill=colors[level]) #shape="SHAPE_ROUND_RECTANGLE") subtopic.set_style(topicstyle) node[level].append([subtopic]) dprint(level, ":", node[level]) if ((level > 0) and node[last]): node[last][len(node[last])-1].append([len(node[level])-1]) dprint("prev:", node[last]) dprint('-'*60) dprint(len(node), range(len(node)-1)) dprint(node) dprint("-----") for start_index in range(len(node)-2): dprint("len ==>", range(len(node[start_index]))) for next_index in range(len(node[start_index])): dprint(start_index, "==>", node[start_index][next_index][0]) for elem in range(1,len(node[start_index][next_index])): dprint ("@:", node[start_index][next_index][elem][0]) dprint ("@@@:", node[start_index+1][node[start_index][next_index][elem][0]][0]) if (len(node) > 1): xmind.save(OUTPUT) print("Saved to", os.path.join(os.getcwd(),OUTPUT)) if debug: xmind.pretty_print()
# -*- coding: utf-8 -*- # (c) 2008, Marcin Kasperski """ Prawdziwe uruchomienie """ from __future__ import print_function from mekk.xmind import XMindDocument import six OUTPUT = "test.xmind" xmind = XMindDocument.create(six.u("Główna kartka"), six.u("Luźne pomysły")) first_sheet = xmind.get_first_sheet() root_topic = first_sheet.get_root_topic() root_topic.add_subtopic(six.u("Pierwszy")) root_topic.add_subtopic(six.u("Drugi")) t = root_topic.add_subtopic(six.u("Trzeci")) t.add_subtopic(six.u("Trzeci i pół")) t.add_subtopic(six.u("Trzeci i półtora")) root_topic.add_subtopic(six.u("Wolnogłówny"), detached=True) t.add_subtopic(six.u("Wolnopodtrzeci"), detached=True) t.add_marker("flag-red") root_topic.add_subtopic(six.u("Linkowany")).set_link("http://mekk.waw.pl") root_topic.add_subtopic(six.u("Załączony")).set_attachment( file("map_creator.py").read(), ".txt") root_topic.add_subtopic(six.u("Z notką")).set_note( six.u("""Ala ma kota i zażółca gęślą jaźń od wieczora do rana."""))
from __future__ import print_function # -*- coding: utf-8 -*- # (c) 2008, Marcin Kasperski from mekk.xmind import XMindDocument import six OUTPUT = "test_eng.xmind" xmind = XMindDocument.create(six.u("First sheet title"), six.u("Root subject")) first_sheet = xmind.get_first_sheet() root_topic = first_sheet.get_root_topic() root_topic.add_subtopic(six.u("First item")) root_topic.add_subtopic(six.u("Second item")) t = root_topic.add_subtopic(six.u("Third item")) t.add_subtopic(six.u("Second level - 1")) t.add_subtopic(six.u("Second level - 2")) root_topic.add_subtopic(six.u("Detached topic"), detached=True) t.add_subtopic(six.u("Another detached"), detached=True) t.add_marker("flag-red") root_topic.add_subtopic(six.u("Link example")).set_link("http://mekk.waw.pl") root_topic.add_subtopic(six.u("Attachment example")).set_attachment( file("map_creator.py").read(), ".txt") root_topic.add_subtopic(six.u("With note")).set_note( six.u("""Ala ma kota i zażółca gęślą jaźń od wieczora do rana.""")) MARKER_CODE = "40g6170ftul9bo17p1r31nqk2a" XMP = "../../py_mekk_nozbe2xmind/src/mekk/nozbe2xmind/NozbeIconsMarkerPackage.xmp"