Changeset View
Changeset View
Standalone View
Standalone View
pykolab/xml/note.py
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | def set_classification(self, classification): | ||||
raise ValueError, _("Invalid classification %r") % (classification) | raise ValueError, _("Invalid classification %r") % (classification) | ||||
def add_category(self, category): | def add_category(self, category): | ||||
_categories = self.categories() | _categories = self.categories() | ||||
_categories.append(ustr(category)) | _categories.append(ustr(category)) | ||||
self.setCategories(_categories) | self.setCategories(_categories) | ||||
def _translate_value(self, val, map): | def _translate_value(self, val, map): | ||||
name_map = dict([(v, k) for (k, v) in map.iteritems()]) | name_map = dict([(v, k) for (k, v) in map.items()]) | ||||
return name_map[val] if name_map.has_key(val) else 'UNKNOWN' | return name_map[val] if name_map.has_key(val) else 'UNKNOWN' | ||||
def to_dict(self): | def to_dict(self): | ||||
if not self.isValid(): | if not self.isValid(): | ||||
return None | return None | ||||
data = dict() | data = dict() | ||||
for p, getter in self.properties_map.iteritems(): | for p, getter in self.properties_map.items(): | ||||
val = None | val = None | ||||
if hasattr(self, getter): | if hasattr(self, getter): | ||||
val = getattr(self, getter)() | val = getattr(self, getter)() | ||||
if isinstance(val, kolabformat.cDateTime): | if isinstance(val, kolabformat.cDateTime): | ||||
val = xmlutils.from_cdatetime(val, True) | val = xmlutils.from_cdatetime(val, True) | ||||
elif isinstance(val, kolabformat.vectori): | elif isinstance(val, kolabformat.vectori): | ||||
val = [int(x) for x in val] | val = [int(x) for x in val] | ||||
elif isinstance(val, kolabformat.vectors): | elif isinstance(val, kolabformat.vectors): | ||||
Show All 19 Lines |