Changeset View
Changeset View
Standalone View
Standalone View
pykolab/xml/attendee.py
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | def get_role(self, translated=False): | ||||
if translated: | if translated: | ||||
return self._translate_value(role, self.role_map) | return self._translate_value(role, self.role_map) | ||||
return role | return role | ||||
def get_rsvp(self): | def get_rsvp(self): | ||||
return self.rsvp() | return self.rsvp() | ||||
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 val in name_map else 'UNKNOWN' | return name_map[val] if val in name_map else 'UNKNOWN' | ||||
def set_cutype(self, cutype): | def set_cutype(self, cutype): | ||||
if cutype in self.cutype_map: | if cutype in self.cutype_map: | ||||
self.setCutype(self.cutype_map[cutype]) | self.setCutype(self.cutype_map[cutype]) | ||||
elif cutype in self.cutype_map.values(): | elif cutype in self.cutype_map.values(): | ||||
self.setCutype(cutype) | self.setCutype(cutype) | ||||
else: | else: | ||||
Show All 21 Lines | class Attendee(kolabformat.Attendee): | ||||
def set_rsvp(self, rsvp): | def set_rsvp(self, rsvp): | ||||
self.setRSVP(rsvp) | self.setRSVP(rsvp) | ||||
def to_dict(self): | def to_dict(self): | ||||
data = self.contactreference.to_dict() | data = self.contactreference.to_dict() | ||||
data.pop('type', None) | data.pop('type', None) | ||||
for p, getter in self.properties_map.iteritems(): | for p, getter in self.properties_map.items(): | ||||
val = None | val = None | ||||
args = {} | args = {} | ||||
if hasattr(self, getter): | if hasattr(self, getter): | ||||
if getter.startswith('get_'): | if getter.startswith('get_'): | ||||
args = dict(translated=True) | args = dict(translated=True) | ||||
val = getattr(self, getter)(**args) | val = getattr(self, getter)(**args) | ||||
if val is not None: | if val is not None: | ||||
data[p] = val | data[p] = val | ||||
Show All 21 Lines |