예제 #1
0
def get_tasks(path):
    xmind = XMindDocument.open(path)
    map_tasks = get_tasks_from_xdoc(xmind)
    response = {}
    response['sheets'] = map_tasks
    response['file_name'] = os.path.basename(path)
    return response
예제 #2
0
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)
예제 #3
0
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
예제 #4
0
def processXmindFile(filename):
    voidPath()
    xmindDoc=XMindDocument.open(filename)
    s1=xmindDoc.get_first_sheet()
    r1=s1.get_root_topic()
    values=xmindWalk_getMarkers(r1,[])
    markers=ET.parse(targetArchiveDir+"markerSheet.xml").getroot().getchildren()[0]
    dico=buildDico(markers)
    createArchive(dico,values)
    attachXMP(filename,xmindDoc)
예제 #5
0
def parse_and_print(file_name):
    xmind = XMindDocument.open(file_name)

    sheet = xmind.get_first_sheet()
    print "Sheet title: ", sheet.get_title()

    root = sheet.get_root_topic()
    print "Root title: ", root.get_title()
    print "Root note: ", root.get_note()

    for topic in root.get_subtopics():
        print "* ", topic.get_title()
        print "   label: ", topic.get_label()
        print "   link: ", topic.get_link()
        print "   markers: ", list(topic.get_markers())
예제 #6
0
def parse_and_print(file_name):
    xmind = XMindDocument.open(file_name)

    sheet = xmind.get_first_sheet()
    print("Sheet title: ", sheet.get_title())

    root = sheet.get_root_topic()
    print("Root title: ", root.get_title())
    print("Root note: ", root.get_note())

    for topic in root.get_subtopics():
        print("* ", topic.get_title())
        print("   label: ", topic.get_label())
        print("   link: ", topic.get_link())
        print("   markers: ", list(topic.get_markers()))
예제 #7
0
    def get_total_list(self):

        xmind = XMindDocument.open(self.file_dir)
        sheet = xmind.get_first_sheet()
        root = sheet.get_root_topic()
        root_title = root.get_title()
        fist_node = root.get_subtopics()
        # print 'fist_node',fist_node

        fist_node_list = []
        sencond_node_list = []
        third_node_list = []
        total_third_node_list = []
        four_node_list = []
        total_four_node_list = []
        five_node_list = []
        total_five_node_list = []
        six_node_list = []
        total_six_node_list = []
        for sencond_node in fist_node:
            sencond_node_list.append(sencond_node.get_title())
            fist_node_list.append(sencond_node.get_title())
            for third_node in sencond_node.get_subtopics():
                third_node_list.append(third_node.get_title())
                for four_node in third_node.get_subtopics():
                    four_node_list.append(four_node.get_title())
                    for five_node in four_node.get_subtopics():
                        five_node_list.append(five_node.get_title())
                        for six_node in five_node.get_subtopics():
                            six_node_list.append(six_node.get_title())
                        total_six_node_list.append(six_node_list)
                        six_node_list = []
                    total_five_node_list.append(five_node_list)
                    five_node_list = []
                total_four_node_list.append(four_node_list)
                four_node_list = []
            total_third_node_list.append(third_node_list)
            third_node_list = []
        return fist_node_list, total_third_node_list, total_four_node_list, total_five_node_list, total_six_node_list, root_title
예제 #8
0
    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()
예제 #9
0
def updateMarkers(filename):
    xmindfile = XMindDocument.open(filename)
    xmindfile.embed_markers("livemappingMarkers.xmp")
    xmindfile.save(filename)
예제 #10
0
 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()
예제 #11
0
    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()
예제 #12
0
Manual=True
if(Manual):
    Xmindfile=raw_input("name of your xmind file : ")
else :
    Xmindfile="article.xmind"

pref_target = re.compile('('
               +'\('
               +'ref'
               +'\)'
               +')')
pref_source = re.compile('('
               +'___'
               +'.*?'
               +'\)___)')
xmind = XMindDocument.open(Xmindfile)
first_sheet = xmind.get_first_sheet()
root_topic = first_sheet.get_root_topic()
#style=root_topic.get_style()
#print(style)
markers=(dropDuplicate(xmindWalk_getMarkers(root_topic)))
markers.append("none")
message="Your markers are : "
for i,marker in enumerate(markers):
    message+=marker+"("+str(i)+") ; "
print message[0:-2]
if(Manual):
    titleId=int(raw_input("choose the index of marker for title (choose none if none ) : "))
    textId=int(raw_input("choose the index of marker for full text (choose none if none ) : "))
    refsId=int(raw_input("choose the index of marker for references (choose none if none ) : "))
    output=raw_input("choose the name of the file that will be created : ")
예제 #13
0
def process_xmind_file(xmind_file='mmaps.xmind'):

    xmind = XMindDocument.open(xmind_file)

    for sheet in xmind.get_all_sheets():

        print "Sheet title: ", sheet.get_title()

        root = sheet.get_root_topic()
        root_title = root.get_title()
        print "Root title: ", root.get_title()
        print "Root note: ", root.get_note()
        level = 0

        #add year and question title
        sheet_id = add_sheet(sheet.get_title(), root_title)

        #direct parent, that is the titles
        for topic in root.get_subtopics():
            topic_name = r'' + topic.get_title()
            print "* ", topic.get_title()

            visible_in_menu = 1
            level = 0
            is_ignored = False
            is_numbered = False
            topic_number = 0
            internal_topic_number = 0

            #split to find numbering and any ignore flag
            topic_name_parts = topic_name.split(TOPIC_DELIMITER)
            topic_name_parts_len = len(topic_name_parts)

            if topic_name_parts_len == 4:
                topic_name = topic_name_parts[3].strip()
                is_ignored = True

                try:
                    topic_number = int(topic_name_parts[1])
                    is_numbered = True

                except:
                    print 'Error parsing number in topic ' + topic_name
                    is_numbered = False

            elif topic_name_parts_len == 3:
                topic_name = topic_name_parts[2].strip()
                is_ignored = False

                try:
                    topic_number = int(topic_name_parts[1])
                    is_numbered = True

                except:
                    print 'Error parsing number in topic ' + topic_name
                    is_numbered = False

            else:
                is_numbered = False
                is_ignored = False

            if is_numbered is False:
                internal_topic_number += 1
                topic_number = internal_topic_number

            if is_ignored is True:
                visible_in_menu = 0

            topic_id = add_topic(sheet_id=sheet_id,
                                 topic_name=topic_name,
                                 topic_parent=None,
                                 is_answer=False,
                                 level=level,
                                 order=topic_number,
                                 visible_menu=visible_in_menu)
            #increment order
            print 'Number: ' + str(topic_number) + ' -' + str(topic_id)

            #children nodes, that's the answers
            for topic_1 in topic.get_subtopics():
                topic_1_name = topic_1.get_title()
                level = 1
                topic_1_id = add_topic(sheet_id=sheet_id,
                                       topic_name=topic_1_name,
                                       topic_parent=topic_id,
                                       is_answer=1,
                                       level=level,
                                       order=topic_number,
                                       visible_menu=0)

                print 'Answer: ' + str(topic_1_id)

            print ''
            print '----------------------------'
예제 #14
0
# -*- 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."""))
예제 #15
0
        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'
               +'.*?'
               +'\)'
               +')')
예제 #16
0
from __future__ import print_function
from mekk.xmind import XMindDocument

xmind = XMindDocument.open("openEHR-EHR-OBSERVATION.apgar.v1.xmind")

ccd_sheet = xmind.get_first_sheet()

ccd = ccd_sheet.get_root_topic()
print("CCD Title:       ", ccd.get_title())
print("CCD Template Id: ", ccd.get_correlation_id())
# here we need to compare the id to know which CCD template is being used.

for top_item in ccd.get_subtopics():  #current level
    if top_item.get_title() == 'definition':
        for level2item in top_item.get_subtopics(): # next level generator
            print("* ", level2item.get_title())
            for level3item in level2item.get_subtopics():
                print("** ", level3item.get_title())
예제 #17
0
def getSheet(file):
    xmindf = XMindDocument.open(file)
    sheet = xmindf.get_first_sheet()
    print "画布名称:", sheet.get_title()
    return sheet
예제 #18
0
def open_doc(name):
    if not os.path.isfile(name):
        name = os.path.join("tests", name)
    return XMindDocument.open(name)
예제 #19
0
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"