Sets known metadata properties satisfying the specified predicate.
The operation is recursive, affecting all nested packages as well. This method combines the behavior of MetadataPackage.AddProperties and MetadataPackage.UpdateProperties. If an existing property satisfies the predicate, its value is updated; if a known property that satisfies the predicate is missing, it is added to the package.
Please note that GroupDocs.Metadata implicitly checks the type of each filtered property. It’s impossible to set a property with a value having inappropriate type.
defset_properties(self,predicate,value):...
Parameter
Type
Description
predicate
Func[MetadataProperty, bool]
A callable that receives a MetadataProperty and returns bool, used to test each metadata property for a condition.
value
PropertyValue
A PropertyValue representing the new value for the filtered properties.
Returns: int: The number of affected properties.
Example
fromdatetimeimportdatetimefromgroupdocs.metadataimportMetadatafromgroupdocs.metadata.commonimportPropertyValuefromgroupdocs.metadata.taggingimportTagsdefset_metadata_properties():withMetadata("input.vsdx")asmetadata:# The value to write into every matching propertyproperty_value=PropertyValue(datetime.now())# set_properties = add-or-update: the predicate selects the# "created" and "modified" date/time properties across all packagesaffected=metadata.set_properties(lambdap:Tags.time.createdinlist(p.tags)orTags.time.modifiedinlist(p.tags),property_value,)print(f"Properties set: {affected}")# Persist the changes to a new filemetadata.save("output.vsdx")