From ad6333b51e666627ec5aa00fc9f600aae1a657d4 Mon Sep 17 00:00:00 2001 From: akuker Date: Fri, 8 Mar 2024 16:23:17 -0600 Subject: [PATCH] Allow additional arguments to be passed through serialize() --- vobject/base.py | 4 ++-- vobject/behavior.py | 2 +- vobject/vcard.py | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/vobject/base.py b/vobject/base.py index dc8a27b..8712752 100644 --- a/vobject/base.py +++ b/vobject/base.py @@ -239,7 +239,7 @@ def transformChildrenFromNative(self, clearBehavior=True): """ pass - def serialize(self, buf=None, lineLength=75, validate=True, behavior=None): + def serialize(self, buf=None, lineLength=75, validate=True, behavior=None, *args, **kwargs): """ Serialize to buf if it exists, otherwise return a string. @@ -251,7 +251,7 @@ def serialize(self, buf=None, lineLength=75, validate=True, behavior=None): if behavior: if DEBUG: logger.debug("serializing {0!s} with behavior {1!s}".format(self.name, behavior)) - return behavior.serialize(self, buf, lineLength, validate) + return behavior.serialize(self, buf, lineLength, validate, *args, **kwargs) else: if DEBUG: logger.debug("serializing {0!s} without behavior".format(self.name)) diff --git a/vobject/behavior.py b/vobject/behavior.py index 0f2cd41..a1a292e 100644 --- a/vobject/behavior.py +++ b/vobject/behavior.py @@ -141,7 +141,7 @@ def generateImplicitParameters(cls, obj): pass @classmethod - def serialize(cls, obj, buf, lineLength, validate=True): + def serialize(cls, obj, buf, lineLength, validate=True, *args, **kwargs): """ Set implicit parameters, do encoding, return unicode string. diff --git a/vobject/vcard.py b/vobject/vcard.py index 1941e82..de3388f 100644 --- a/vobject/vcard.py +++ b/vobject/vcard.py @@ -226,7 +226,7 @@ def valueRepr(cls, line): return " (BINARY PHOTO DATA at 0x{0!s}) ".format(id(line.value)) @classmethod - def serialize(cls, obj, buf, lineLength, validate): + def serialize(cls, obj, buf, lineLength, validate, *args, **kwargs): """ Apple's Address Book is *really* weird with images, it expects base64 data to have very specific whitespace. It seems Address Book @@ -234,8 +234,7 @@ def serialize(cls, obj, buf, lineLength, validate): """ if wacky_apple_photo_serialize: lineLength = REALLY_LARGE - VCardTextBehavior.serialize(obj, buf, lineLength, validate) - + VCardTextBehavior.serialize(obj, buf, lineLength, validate, *args, **kwargs) registerBehavior(Photo)