1
#!/usr/bin/env python2.3
5
class Bookmark(object):
6
def __init__(self, id=None, page_url=None, category=None,
9
# the primary id of this bookmark (a unique int identifier)
12
# the url of the local page this link belongs to
13
self.page_url = page_url
15
# the heading under which this link should appear
16
self.category = category
18
# the displayed name of this link (appears between the <a> and </a>)
21
# the url this link points to (the <a href=> points here)
24
def _get_csv_row(self):
25
attrib_list = [self.category, self.url, self.id, self.name, self.page_url]
26
return [a for a in attrib_list if a]
27
csv_row = property(_get_csv_row, doc='''returns a list representation
28
of this object properly formatted for writing to our CSVStorage module''')
30
def matches_values(self, **kwargs):
31
'''tests to see if this bookmark matches the attribute values
32
given as kwargs. returns a boolean value'''
33
for key, val in kwargs.iteritems():
34
if not getattr(self, key) == val:
38
def __cmp__(self, other):
39
if (self.id == other.id and
40
self.page_url == other.page_url and
41
self.category == other.category and
42
self.name == other.name and
43
self.url == other.url):
50
iter = self.__dict__.iteritems()
53
astr = ''.join([astr, '%s: %s\n' % iter.next()])