Liblarch, a python library to handle trees and acyclic graphs
by Ploum on 2012-11-08
Lesson number one
Some of you may be aware that Getting Things GNOME! 0.3 was released. What you may not know is that GTG is now using a python library called liblarch and that liblarch 2.1.0 was released today.
Liblarch is a python library specifically designed to handle complex trees (including directed acyclic graphs) and to display them. A liblarch-gtk component allows you to display different views of your tree in a GTK TreeView widget without any effort.
During the development of GTG, we faced major problems to handle our tree of tasks and our tree of tags. The features we wanted proved to be very complex to implement and very fragile : solving a bug would create two others. And the performance work was a nightmare.
We decided to abstract the whole concept of tree and to make it a standalone, well tested and optimized library. We are very proud of it and we are looking for more applications that would benefit from using liblarch.
Liblarch is designed to be as simple as possible from the programmer point of view. The nodes of your tree can be any python object. You only need to inherit from liblarch TreeNode. Once you have a node, you will connect it to a tree. It can be a node without parent, with a single parent or even with multiple parents.
Where liblarch becomes powerful is to display a given tree : you can have multiple views over the same tree, add a complex filter or even a combination of multiple filters. And all of that can be quite easily displayed in a GTK TreeView. Easy and GTK TreeView in the same sentence? Sounds impossible? Not with liblarch!
How liblarch is working
As an example, you can test our implemenation of a dummy contact list. By reading the code, you will see how straightfoward it is to have searching capabilities in the contact list, contacts in multiple groups, hiding offline contacts or updating automatically when a new contact comes online.
Liblarch comes with an extensive test suite. The next challenge is to port it to Python3/GTK3 and to write a good built-in documentation. Any help is welcome 🙂 (EDIT: we are also looking for packagers)
As a writer and an engineer, I like to explore how technology impacts society. You can subscribe by email or by rss. I value privacy and never share your adress.
If you read French, you can support me by buying/sharing/reading my books and subscribing to my newsletter in French or RSS. I also develop Free Software.