Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
eclipse.preferences.version=1
encoding//xmind/__init__.py=utf-8
encoding//xmind/core/__init__.py=utf-8
encoding//xmind/core/const.py=utf-8
encoding//xmind/core/loader.py=utf-8
encoding//xmind/core/notes.py=utf-8
encoding//xmind/core/workbook.py=utf-8
encoding//xmind/framework/Enum.py=utf-8
encoding//xmind/framework/UnitTest.py=utf-8
encoding//xmind/framework/__init__.py=utf-8
encoding//xmind/import_export/ExportFilter.py=utf-8
encoding//xmind/import_export/GraphvizExportFilter.py=utf-8
encoding//xmind/import_export/__init__.py=utf-8
encoding//xmind/utils.py=utf-8
encoding/example.py=utf-8
encoding/setup.py=utf-8
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
#XMind SDK for python
#Fork of XMind SDK for python with extensions for import / export (e.g. Graphviz)

**XMind SDK for python** to help Python developers to easily work with XMind files and build XMind extensions.

##Install XMind SDK for python

Clone the repository to a local working directory

git clone https://github.com/xmindltd/xmind-sdk-python.git
git clone https://github.com/Almerxsese/xmind-sdk-python

Now there will be a directory named `xmind-sdk-python` under the current directory. Change to the directory `xmind-sdk-python` and install **XMind SDK for python**.

python setup.py install

*It is highly recommended to install __XMind SDK for python__ under an isolated python environment using [virtualenv](https://pypi.python.org/pypi/virtualenv)*

##Set PYTHONPATH
You must set PYTHONPATH environment variable to '.'.

In Eclipse (with PyDev plugin): modify the 'Run Configuration' and define varaiable PYTHONPATH = . (with the
'Environment' Tab)

##Usage

Open an existing XMind file or create a new XMind file and place it into a given path
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

setup(
name="xmind",
version="0.1a.0",
version="0.0.1",
packages=find_packages(),

install_requires=["distribute"],

author="Woody Ai",
author_email="aiqi@xmind.net",
description="The offical XMind python SDK",
author="Michel Kern",
author_email="echopraxium@yahoo.com",
description="A fork of XMind python SDK with extensions for import / export (e.g. Graphviz)",
license="MIT",
keywords="XMind, SDK, mind mapping",
url="https://github.com/xmindltd/xmind-sdk-python"
keywords="XMind, SDK, mind mapping, extension, import, export, graphviz",
url="https://github.com/Almerxsese/xmind-sdk-python"
)
1 change: 1 addition & 0 deletions xmind/data/sample_text_file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
74 changes: 74 additions & 0 deletions xmind/framework/Enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
xmind.framework.Enum
~~~~~~~~~~~~~~~~~
:mod:``xmind.framework.Enum`` provides an support for an enumerated type
:copyright: http://code.activestate.com/recipes/413486-first-class-enums-in-python/
:copyright: Zoran Isailovski
:license: PSF
:note: source code copied from 'First Class Enums in Python (Python recipe)':
http://code.activestate.com/recipes/413486-first-class-enums-in-python/
"""

__author__ = "http://code.activestate.com/recipes/users/2400454/ <Zoran Isailovski>"

#------------------- Enum -------------------
def Enum(*names):
##assert names, "Empty enums are not supported" # <- Don't like empty enums? Uncomment!

class EnumClass(object):
__slots__ = names
def __iter__(self): return iter(constants)
def __len__(self): return len(constants)
def __getitem__(self, i): return constants[i]
def __repr__(self): return 'Enum' + str(names)
def __str__(self): return 'enum ' + str(constants)

class EnumValue(object):
__slots__ = ('__value')
def __init__(self, value): self.__value = value
Value = property(lambda self: self.__value)
EnumType = property(lambda self: EnumType)
def __hash__(self): return hash(self.__value)
def __cmp__(self, other):
# C fans might want to remove the following assertion
# to make all enums comparable by ordinal value {;))
assert self.EnumType is other.EnumType, "Only values from the same enum are comparable"
return cmp(self.__value, other.__value)
def __invert__(self): return constants[maximum - self.__value]
def __nonzero__(self): return bool(self.__value)
def __repr__(self): return str(names[self.__value])

maximum = len(names) - 1
constants = [None] * len(names)
for i, each in enumerate(names):
val = EnumValue(i)
setattr(EnumClass, each, val)
constants[i] = val
constants = tuple(constants)
EnumType = EnumClass()
return EnumType
#------------------- Enum

#======================== main ========================
def main():
print("** xmind.framework.Enum **")

print '\n*** Enum Demo ***'
print '--- Days of week ---'
Days = Enum('Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su')
print Days
print Days.Mo
print Days.Fr
print Days.Mo < Days.Fr
print list(Days)
for each in Days:
print 'Day:', each
print '--- Yes/No ---'
Confirmation = Enum('No', 'Yes')
answer = Confirmation.No
print 'Your answer is not', ~answer

if __name__ == '__main__':
main()
30 changes: 30 additions & 0 deletions xmind/framework/UnitTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
xmind.framework.UnitTest
------------------------
:mod: ``xmind.framework.UnitTest`` provides unit test superclass
:copyright: Michel Kern
:license: MIT
"""

__author__ = "echopraxium@yahoo.com <Michel Kern>"

#------------------- UnitTest -------------------
class UnitTest:
def __init__(self):
self.name = "unit_test"

def run(self):
print("> run '" + self.name + "'")
#------------------- UnitTest

#======================== main ========================
def main():
print("** xmind.framework.UnitTest **")

ut = UnitTest()
ut.run()

if __name__ == '__main__':
main()
17 changes: 17 additions & 0 deletions xmind/framework/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
xmind.framework
---------------
:copyright: Michel Kern
:license: MIT

"""
__author__ = "echopraxium@yahoo.com <Michel Kern>"

#======================== main ========================
def main():
print("** xmind.framework module **")

if __name__ == '__main__':
main()
46 changes: 46 additions & 0 deletions xmind/import_export/ExportFilter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
xmind.import_export.ExportFilter
--------------------------------
:mod: ``xmind.import_export.ExportFilter`` provide a handy way for exporting / importing
XMind files to other formats (e.g: GraphViz).
:copyright: Michel Kern
:license: MIT
"""

__author__ = "echopraxium@yahoo.com <Michel Kern>"

import os
import os.path
from xmind.framework.Enum import Enum

FILE_NOT_FOUND_ERROR = 1
EMPTY_OUTPUT_FILE_PATH_ERROR = 2
RETURN_CODE = Enum('OK', 'FILE_NOT_FOUND_ERROR', 'EMPTY_OUTPUT_FILE_PATH_ERROR')

#------------------- ExportFilter -------------------
class ExportFilter():
def __init__(self):
self.name = "export_filter"

#---------- export() ----------
def export(self, source_path, target_path):
print(self.name + ".export ")
if (not os.path.isfile(source_path)):
print("source_path: '" + source_path + "' not found")
exit(RETURN_CODE.FILE_NOT_FOUND_ERROR)
return RETURN_CODE.OK
#---------- export()
#------------------- ExportFilter

#======================== main ========================
def main():
print("** xmind.ExportFilter **")
export_filter = ExportFilter()
rc = export_filter.export("../data/sample_text_file.txt", "")
print(rc)
#pass

if __name__ == '__main__':
main()
Loading