Xmind Mindmaps konvertieren

Monday, April 9. 2012

There is prior post regarding conversion of .xmind documents to other mind mapping formats and also re: import of text to Freemind, but now there is a new angle to those topics after I discovered a python modul which comes quite handy if you want to parse or create .xmind mindmaps. 

It goes by the name of mekk.xmind, authered by Marcin Kasperski. 

Download it with mercurial, (if you don't have this installed, you can get it on debian by apt-get install mercurial)

hg clone https://bitbucket.org/Mekk/mekk.xmind
cd mekk.xmind
python setup.py install

You will find some example scripts next to he sources and it worked fine here immediately..

Frustrated over Kontact I still search for a suitable way to handle task lists so that task administration integrates with my desktop thunderbird/lightning, google calendars and my androisd smartphone which nicely interfaces to google tasks. And as I like to structure my ideas with mindmaps and quite like XMind I tried to use XMind as a means to write structured task lists. Unfortunately lightning doesn't do subtasks. It has been asked for for years but not implemented.

Among the alternatives for task managment on linux there is  Task Coach (pro: open source, does sub tasks SyncML, file format XML, some export options, con: usage could need enhancement, export formats uncomplete, so after reimporting an exported task list it doesn't necessarily rebuild the same thing, supports iOS but no direct support for android). For android they recommend  Todo.txt and task coach exports and imports task lists in todo.tx - Format. 

Can't say I'm content with all this, it's more like a waypoint on my search. Below is a little python script that lets you excerpt a todo.txt task list from an xMind mindmap.

 

#!/usr/bin/python
# -*- coding: utf-8 -*-

# (c) 2012, Daniel Plaenitz
#
# depends on mekk.xmind by Marcin Kasperski
# hg clone https://bitbucket.org/Mekk/mekk.xmind
#

# python xmind2todo.py inputFile [outputFile]

from mekk.xmind import XMindDocument

from datetime import date
import sys
import codecs

output = u""

def parse_sheet(file_name):
    xmind = XMindDocument.open(file_name)
    sheet = xmind.get_first_sheet()
    root = sheet.get_root_topic()
    
    for topic in root.get_subtopics():
        parse_level(topic,[],root.get_title())


def parse_level(topic,names,rootTitle):
    global output
   
    _names = names[:]
    _names.append(topic.get_title())
    _line = u""
    
    for name in _names:
        _line += u" -> "+name
    
    _line = _line[4:]
    _line = " ".join(_line.split('\n'))
    
    _prio = u""
    if 'priority-1' in list(topic.get_markers()):
        _prio = "(A) "
    elif 'priority-2' in list(topic.get_markers()):
        _prio = "(B) "
    elif 'priority-3' in list(topic.get_markers()):
        _prio = "(C) "   
    elif 'priority-4' in list(topic.get_markers()):
        _prio = "(D) "
    elif 'priority-5' in list(topic.get_markers()):
        _prio = "(E) "
    elif 'priority-6' in list(topic.get_markers()):
        _prio = "(F) "
    
    if 'task-done' in list(topic.get_markers()):
        _prio = u"x " + _prio
        
    _line = _prio + date.today().isoformat() + " " + _line
    _line += " +"+rootTitle
    
    
    output += _line + "\n"
    
    for stopic in topic.get_subtopics():
        parse_level(stopic,_names,rootTitle)
        
def main(argv):
    global output

    if len(argv) < 1 :
        print "xmind2todo.py inputFile [outputFile]"
        sys.exit(2)  
        
    infilePath = argv[0]
    outfilePath =  infilePath+".txt"
    
    if (len(argv) > 1):
        outfilePath = argv[1]

    parse_sheet(infilePath)
        
    print "writing to "+outfilePath    
    f = codecs.open(outfilePath, encoding='utf-8', mode='w')
    f.write( output )
    
if __name__ == "__main__":
    main(sys.argv[1:])
 

 

(Page 1 of 1, totaling 1 entries)