enable content_line method, which seem to be a good thing. it's also defined in RFC5545
Johannes Raggam
11 years ago
68 | 68 | # component, we will silently ignore |
69 | 69 | # it, rather than let the exception |
70 | 70 | # propagate upwards |
71 | # not_compliant = [''] # List of non-compliant properties. | |
71 | 72 | |
72 | 73 | def __init__(self, *args, **kwargs): |
73 | 74 | """Set keys to upper for initial dict. |
78 | 79 | self.subcomponents = [] # Components can be nested. |
79 | 80 | self.is_broken = False # True iff we ignored an exception while parsing a property |
80 | 81 | |
81 | # def non_complience(self, warnings=0): | |
82 | # """ | |
83 | # not implemented yet! | |
84 | # Returns a dict describing non compliant properties, if any. | |
85 | # If warnings is true it also returns warnings. | |
86 | # | |
87 | # If the parser is too strict it might prevent parsing erroneous but | |
88 | # otherwise compliant properties. So the parser is pretty lax, but it is | |
89 | # possible to test for non-complience by calling this method. | |
90 | # """ | |
91 | # nc = {} | |
92 | # if not getattr(self, 'name', ''): | |
93 | # nc['name'] = {'type':'ERROR', 'description':'Name is not defined'} | |
94 | # return nc | |
82 | #def is_compliant(self, name): | |
83 | # """Returns True is the given property name is compliant with the | |
84 | # icalendar implementation. | |
85 | # | |
86 | # If the parser is too strict it might prevent parsing erroneous but | |
87 | # otherwise compliant properties. So the parser is pretty lax, but it is | |
88 | # possible to test for non-complience by calling this method. | |
89 | # """ | |
90 | # return name in not_compliant | |
91 | ||
95 | 92 | |
96 | 93 | ############################# |
97 | 94 | # handling of property values |
316 | 313 | def __repr__(self): |
317 | 314 | return '%s(%s)' % (self.name, data_encode(self)) |
318 | 315 | |
319 | # def content_line(self, name): | |
320 | # "Returns property as content line" | |
321 | # value = self[name] | |
322 | # params = getattr(value, 'params', Parameters()) | |
323 | # return Contentline.from_parts((name, params, value)) | |
316 | def content_line(self, name, value): | |
317 | """Returns property as content line. | |
318 | """ | |
319 | params = getattr(value, 'params', Parameters()) | |
320 | return Contentline.from_parts((name, params, value)) | |
324 | 321 | |
325 | 322 | def content_lines(self): |
326 | 323 | """Converts the Component and subcomponents into content lines. |
327 | ||
328 | 324 | """ |
329 | 325 | contentlines = Contentlines() |
330 | for name, values in self.property_items(): | |
331 | params = getattr(values, 'params', Parameters()) | |
332 | contentlines.append(Contentline.from_parts((name, params, values))) | |
326 | for name, value in self.property_items(): | |
327 | cl = self.content_line(name, value) | |
328 | contentlines.append(cl) | |
333 | 329 | contentlines.append('') # remember the empty string in the end |
334 | 330 | return contentlines |
335 | 331 |