kopia lustrzana https://github.com/collective/icalendar
				
				
				
			Merge remote-tracking branch 'dmikurube/recursive-property_items'
						commit
						be92f23ba8
					
				|  | @ -131,6 +131,17 @@ class Component(CaselessDict): | ||||||
|     >>> [i['dtstart'] for i in c.walk('VEVENT')] |     >>> [i['dtstart'] for i in c.walk('VEVENT')] | ||||||
|     ['20000101T000000'] |     ['20000101T000000'] | ||||||
| 
 | 
 | ||||||
|  |     We can enumerate property items recursively with the property_items method. | ||||||
|  |     >>> c.property_items() | ||||||
|  |     [('BEGIN', 'VCALENDAR'), ('ATTENDEE', vCalAddress('Max M')), ('BEGIN', 'VEVENT'), ('DTEND', '20000102T000000'), ('DTSTART', '20000101T000000'), ('SUMMARY', 'A brief history of time'), ('END', 'VEVENT'), ('END', 'VCALENDAR')] | ||||||
|  | 
 | ||||||
|  |     We can also enumerate property items just under the component. | ||||||
|  |     >>> c.property_items(recursive=False) | ||||||
|  |     [('BEGIN', 'VCALENDAR'), ('ATTENDEE', vCalAddress('Max M')), ('END', 'VCALENDAR')] | ||||||
|  |     >>> sc = c.subcomponents[0] | ||||||
|  |     >>> sc.property_items(recursive=False) | ||||||
|  |     [('BEGIN', 'VEVENT'), ('DTEND', '20000102T000000'), ('DTSTART', '20000101T000000'), ('SUMMARY', 'A brief history of time'), ('END', 'VEVENT')] | ||||||
|  | 
 | ||||||
|     Text fields which span multiple mulitple lines require proper indenting |     Text fields which span multiple mulitple lines require proper indenting | ||||||
|     >>> c = Calendar() |     >>> c = Calendar() | ||||||
|     >>> c['description']=u'Paragraph one\\n\\nParagraph two' |     >>> c['description']=u'Paragraph one\\n\\nParagraph two' | ||||||
|  | @ -320,7 +331,7 @@ class Component(CaselessDict): | ||||||
|     ##################### |     ##################### | ||||||
|     # Generation |     # Generation | ||||||
| 
 | 
 | ||||||
|     def property_items(self): |     def property_items(self, recursive=True): | ||||||
|         """ |         """ | ||||||
|         Returns properties in this component and subcomponents as: |         Returns properties in this component and subcomponents as: | ||||||
|         [(name, value), ...] |         [(name, value), ...] | ||||||
|  | @ -336,9 +347,10 @@ class Component(CaselessDict): | ||||||
|                     properties.append((name, value)) |                     properties.append((name, value)) | ||||||
|             else: |             else: | ||||||
|                 properties.append((name, values)) |                 properties.append((name, values)) | ||||||
|         # recursion is fun! |         if recursive: | ||||||
|         for subcomponent in self.subcomponents: |             # recursion is fun! | ||||||
|             properties += subcomponent.property_items() |             for subcomponent in self.subcomponents: | ||||||
|  |                 properties += subcomponent.property_items() | ||||||
|         properties.append(('END', vText(self.name).to_ical())) |         properties.append(('END', vText(self.name).to_ical())) | ||||||
|         return properties |         return properties | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -121,7 +121,7 @@ class IComponent(Interface): | ||||||
|         Returns sequence of components. |         Returns sequence of components. | ||||||
|         """ |         """ | ||||||
| 
 | 
 | ||||||
|     def property_items(): |     def property_items(recursive=True): | ||||||
|         """Return properties as (name, value) tuples. |         """Return properties as (name, value) tuples. | ||||||
| 
 | 
 | ||||||
|         Returns all properties in this comopnent and subcomponents as |         Returns all properties in this comopnent and subcomponents as | ||||||
|  |  | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Johannes Raggam
						Johannes Raggam