netaneld122 / flexi

Python library to import/export data structures from/to xmls

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flexi

Flexi is a flexible utility that allows you to import and export any tree data structure.

Recent Changes

  • Version 1.0

Usage example

Simple tree operations

# Load the entire xml to memory
root = flexi.load('file.xml')

# Change existing values
root.some_existing_key.test = 3
root.some_existing_list[17].my_value = 3
del root.some_existing_list[17].test

# Create new sub trees
create_sub_tree(root, 'my_tree')
root.my_tree.new_value = 1.2

# Can be shortened to
create_sub_tree(root, 'a.b').value = 1
print root.a.b

# Dump all changes back to disk
flexi.dump(root, 'file.xml')

Adding xml serializers

class MyDataHolder(object):
    data = None

@matches.xml_element('my_tag', attr='foobar')
@matches.python_type(MyDataHolder)
class MyTagSerializer(object):

    def tree_to_xml(self, name, my_data_holder, element):
        # ...

    def xml_to_tree(self, element, tree):
        # ...

How do I get set up?

Make sure you have Python 2.7.

  • setup.py install

About

Python library to import/export data structures from/to xmls

License:MIT License


Languages

Language:Python 100.0%