0.2 Released!
Changes Since TagFu 0.1:
TagFu is a library for tagging entities (which can be anything with a url) with Tags or metadata. TagFu is implemented in Python and very closely mimics basic Python data structures. Tags is a Python list of tags, Entities is a Python List of Entity objects, and Entity is a dict which contains all the key-value pairs for all tags associated to the Entity. The key is the Tag name and value is an arbitrary value, if no value is set, the tag is considered to be a simple tag.
The current direction of development is towards a C port to make binding to other languages easier, and the development of applications to use TagFu.
Bugs can be reported at http://roundup.geekfire.com/tagfu/.
Join us on IRC in #geekfire on irc.freenode.net or we can also be contacted by email at tagfu-devel@geekfire.com. To subscribe send a mail to tagfu-devel+subscribe@geekfire.com.
TagFu can be used for simple tagging tasks much like other tagging libraries such as leaftag. This is possible by simply associating tags to entities with no value. Where TagFu really shines though, is the ability to associate metadata to entities. This feature allows TagFu to be used for associating arbitrary information to an entity without having a specific tagging format for that entity. This feature was inspired by the use of extended attributes in BeOS for a variety of basic functionality such as the handling of mail headers, or for entries in an address book (simply as extattr associated to a file named for the information being represented).
>>> tf = Tagfu()
# add a tag:
>>> tf.tags
[u'title', u'git', u'blah']
>>> tf.tags.append('awesome')
>>> tf.tags
[u'title', u'git', u'blah', u'awesome']
# Manipulate the tags on an entity:
>>> tf.entities
[{u'git': u'', '_id': 1, '_url': u'http://git.geekfire.com/',
u'title': u"Geekfire's gitweb"},
{'_id': 2, '_url': u'file:///home/alex/krb5.conf',
u'title': u'REED.EDU krb5 configuration file'}]
>>> tf.entities[1]
{u'git': u'', '_id': 1, '_url': u'http://git.geekfire.com/',
u'title': u"Geekfire's gitweb"}
>>> tf.entities[1]['title'] = "Geekfire's GitWeb"
>>> tf.entities[1]
{u'git': u'', '_id': 1, '_url': u'http://git.geekfire.com/',
u'title': u"Geekfire's GitWeb"}
>>> del tf.entities[1]['git']
>>> tf.entities[1]
{'_id': 1, '_url': u'http://git.geekfire.com/',
u'title': u"Geekfire's GitWeb"}
>>> tf.entities[1]['git'] = None
>>> tf.entities[1]
{u'git': None, '_id': 1, '_url': u'http://git.geekfire.com/',
u'title': u"Geekfire's GitWeb"}
# add an entity:
>>> tf.entities.append('file:///home/alex/tmp/tagfu-0.1.tar.gz')
3
>>> tf.entities
[{u'git': None, '_id': 1, '_url': u'http://git.geekfire.com/',
u'title': u"Geekfire's GitWeb"},
{'_id': 2, '_url': u'file:///home/alex/krb5.conf',
u'title': u'REED.EDU krb5 configuration file'},
{'_id': 3, '_url': u'file:///home/alex/tmp/tagfu-0.1.tar.gz'}]
>>> tf.entities[3]
{'_id': 3, '_url': u'file:///home/alex/tmp/tagfu-0.1.tar.gz'}
>>> tf.entities[3]['title'] = "The TagFu 0.1 tarball"
>>> tf.entities[3]
{'_id': 3, '_url': u'file:///home/alex/tmp/tagfu-0.1.tar.gz',
u'title': u'The TagFu 0.1 tarball'}
# We can even add a tag indirectly...
>>> tf.entities[3]['tar'] = None
>>> tf.entities[3]
{'_id': 3, u'tar': None, '_url': u'file:///home/alex/tmp/tagfu-0.1.tar.gz',
u'title': u'The TagFu 0.1 tarball'}
>>> tf.tags
[u'title', u'git', u'blah', u'awesome', u'tar']