Bookmark datatype
- From: "Renato Araujo" <renatox gmail com>
- To: conduit-list gnome org
- Subject: Bookmark datatype
- Date: Fri, 7 Sep 2007 20:12:08 -0300
Hi all,
I am creating a new dataprovider to delicious sync, but for this i will need a new datatype to store the bookmark info. What you think about this?
Attached on this message, is the code of my new datatype.
BR
Renato Filho
import conduit
from conduit import log,logd,logw
from conduit.datatypes import DataType
class BookmarkEntry(DataType.DataType):
"""
Represents a Bookmark entry
"""
def __init__(self, **kwargs):
"""
BookmarkEntry constructor.
Compulsory kwargs
- href: the url
Optional kwargs
- description: the entry description
- title: entry title
- mtime: python datetime
- tag: entry tags
"""
DataType.DataType.__init__(self,"bookmarkentry")
self.href = kwargs["href"]
self.description = kwargs.get("description","")
self.title = kwargs.get("title", "")
self.tag = kwargs.get("tag", "")
self.set_mtime(kwargs.get("mtime", None))
def compare(self, B):
"""
Compares two entries: Approach
"""
#Look at the modification times
if self.href == B.href:
return conduit.datatypes.COMPARISON_EQUAL
else
return conduit.datatypes.COMPARISON_UNKNOWN
def set_from_bookmarkentry_string(self, string):
raise NotImplementedError
def get_bookmarkentry_string(self):
return ("Href: %s\nTitle:%s\nDescription:%s\nTag:%s\n(Modified: %s)" % \
(self.href, self.title, self.description, self.tag, self.get_mtime()))
def __getstate__(self):
data = DataType.DataType.__getstate__(self)
data["title"] = self.title
data["href"] = self.href
data["description"] = self.description
data["tag"] = self.tag
return data
def __setstate__(self, data):
self.title = data["title"]
self.href = data["title"]
self.description = data["description"]
self.tag = data["tag"]
DataType.DataType.__setstate__(self, data)
def __str__(self):
return self.href
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]