Giter Site home page Giter Site logo

henrygentry / xmindparser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhangqishou/xmindparser

0.0 1.0 0.0 255 KB

Parse xmind file to programmable data type (e.g. json, xml), support xmind legacy and xmind zen file types.

License: MIT License

Python 100.00%

xmindparser's Introduction

xmindparser

PyPI

Parse xmind file to programmable data type (e.g. json, xml). Python 3.x required. Now it supports XmindZen file type as well.

See also: xmind2testlink / 中文文档

Installation

pip install xmindparser

Usage - Command Line

cd /your/xmind/dir

xmindparser your.xmind -json
xmindparser your.xmind -xml

Note: Parse to xml file type require dicttoxml.

Usage - via Python

from xmindparser import xmind_to_dict

d = xmind_to_dict('/path/to/your/xmind')
print(d)

See example output: json

Configuration

If you use xmindparser via Python, it provides a config object, check this example:

import logging
from xmindparser import xmind_to_dict,config

config = {'logName': 'your_log_name',
          'logLevel': logging.DEBUG,
          'logFormat': '%(asctime)s %(levelname)-8s: %(message)s',
          'showTopicId': True, # internal id will be included, default = False
          'hideEmptyValue': False  # empty values will be hidden, default = True
          }

d = xmind_to_dict('/path/to/your/xmind')
print(d)

Limitations (for Xmind legacy version)

Please note, following xmind features will not be supported or partially supported.

  • Will not parse Pro features, e.g. Task Info, Audio Note
  • Will not parse floating topics.
  • Will not parse linked topics.
  • Will not parse summary info.
  • Will not parse relationship info.
  • Will not parse boundary info.
  • Will not parse attachment object, only name it as [Attachment] - name
  • Will not parse image object, only name it as [Image]
  • Rich text format in notes will be parsed as plain text.

XmindZen Supporting

xmindparser will auto detect xmind file created by XmindZen or XmindPro, you can pass in ZEN file as usual.

from xmindparser import xmind_to_dict

d = xmind_to_dict('/path/to/your/xmind_zen_file')
print(d)

Please note, there are a few differences between xmind legacy and xmind zen.

  • Comments feature removed, so I will not parse it in ZEN.
  • Add feature - sticker, I parse it as image dict type.
  • Add feature - callout, I parse it as list type. (not sure existed in lagacy?)

Since XmindZen has upgraded the internal content file as json, you can read it by code like this:

import json

def get_xmind_zen_json(file_path):
    name = "content.json"
    with ZipFile(file_path) as xmind:
        if name in xmind.namelist():
            content = xmind.open(name).read().decode('utf-8')
            return json.loads(content)

        raise AssertionError("Not a xmind zen file type!")

# xmindparser also provides a shortcut
from xmindparser import get_xmind_zen_builtin_json

content_json = get_xmind_zen_builtin_json(xmind_zen_file)

Examples

Xmind Example

License

MIT

xmindparser's People

Contributors

tobyqin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.