Codebase list python-icalendar / 87791f9
enable content_line method, which seem to be a good thing. it's also defined in RFC5545 Johannes Raggam 11 years ago
1 changed file(s) with 19 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
6868 # component, we will silently ignore
6969 # it, rather than let the exception
7070 # propagate upwards
71 # not_compliant = [''] # List of non-compliant properties.
7172
7273 def __init__(self, *args, **kwargs):
7374 """Set keys to upper for initial dict.
7879 self.subcomponents = [] # Components can be nested.
7980 self.is_broken = False # True iff we ignored an exception while parsing a property
8081
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
9592
9693 #############################
9794 # handling of property values
316313 def __repr__(self):
317314 return '%s(%s)' % (self.name, data_encode(self))
318315
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))
324321
325322 def content_lines(self):
326323 """Converts the Component and subcomponents into content lines.
327
328324 """
329325 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)
333329 contentlines.append('') # remember the empty string in the end
334330 return contentlines
335331