Changeset View
Changeset View
Standalone View
Standalone View
pykolab/xml/note.py
Show All 13 Lines | def note_from_message(message): | ||||
note = None | note = None | ||||
if message.is_multipart(): | if message.is_multipart(): | ||||
for part in message.walk(): | for part in message.walk(): | ||||
if part.get_content_type() == "application/vnd.kolab+xml": | if part.get_content_type() == "application/vnd.kolab+xml": | ||||
payload = part.get_payload(decode=True) | payload = part.get_payload(decode=True) | ||||
note = note_from_string(payload) | note = note_from_string(payload) | ||||
# append attachment parts to Note object | # append attachment parts to Note object | ||||
elif note and part.has_key('Content-ID'): | elif note and 'Content-ID' in part: | ||||
note._attachment_parts.append(part) | note._attachment_parts.append(part) | ||||
return note | return note | ||||
class Note(kolabformat.Note): | class Note(kolabformat.Note): | ||||
type = 'note' | type = 'note' | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | class Note(kolabformat.Note): | ||||
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.iteritems()]) | ||||
return name_map[val] if name_map.has_key(val) else 'UNKNOWN' | return name_map[val] if val in name_map 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.iteritems(): | ||||
Show All 27 Lines |