@@ -58,6 +58,35 @@ def with_uid(self, new_uid):
58
58
59
59
return Item ("\r \n " .join (parsed .dump_lines ()))
60
60
61
+ def without_details (self ):
62
+ """Returns a minimal version of this item.
63
+
64
+ Filters out data to reduce content size and hide private details:
65
+ * Description
66
+ * Location
67
+ * Organizer
68
+ * Attendees list
69
+ * Redundant timezone data (actual timezone of event is preserved)
70
+ """
71
+ parsed = _Component .parse (self .raw )
72
+ stack = [parsed ]
73
+ while stack :
74
+ component = stack .pop ()
75
+
76
+ component .subcomponents = [
77
+ subcomp for subcomp
78
+ in component .subcomponents
79
+ if subcomp .name != "VTIMEZONE"
80
+ ]
81
+ for field in ["DESCRIPTION" , "ORGANIZER" , "ATTENDEE" , "LOCATION" ]:
82
+ # Repeatedly delete because some fields can appear multiple times
83
+ while field in component :
84
+ del component [field ]
85
+
86
+ stack .extend (component .subcomponents )
87
+
88
+ return Item ("\r \n " .join (parsed .dump_lines ()))
89
+
61
90
@cached_property
62
91
def raw (self ):
63
92
"""Raw content of the item, as unicode string.
@@ -241,9 +270,9 @@ class _Component:
241
270
Raw outline of the components.
242
271
243
272
Vdirsyncer's operations on iCalendar and VCard objects are limited to
244
- retrieving the UID and splitting larger files into items. Consequently this
245
- parser is very lazy, with the downside that manipulation of item properties
246
- are extremely costly.
273
+ retrieving the UID, removing fields, and splitting larger files into items.
274
+ Consequently this parser is very lazy, with the downside that manipulation
275
+ of item properties are extremely costly.
247
276
248
277
Other features:
249
278
0 commit comments