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