EBookContacts.VCardAttribute

Fields

None

Methods

class

new (attr_group, attr_name)

add_param (param)

add_param_with_value (param, value)

add_value (value)

add_value_decoded (value, len)

copy ()

free ()

get_group ()

get_name ()

get_param (name)

get_params ()

get_value ()

get_value_decoded ()

get_values ()

get_values_decoded ()

has_type (typestr)

is_single_valued ()

remove_param (param_name)

remove_param_value (param_name, s)

remove_params ()

remove_value (s)

remove_values ()

Details

class EBookContacts.VCardAttribute
classmethod new(attr_group, attr_name)
Parameters:
  • attr_group (str or None) – a group name

  • attr_name (str) – an attribute name

Returns:

A new EBookContacts.VCardAttribute.

Return type:

EBookContacts.VCardAttribute

Creates a new EBookContacts.VCardAttribute with the specified group and attribute names. The attr_group may be None or the empty string if no group is needed.

add_param(param)
Parameters:

param (EBookContacts.VCardAttributeParam) – an EBookContacts.VCardAttributeParam to add

Prepends param to self's list of parameters. This takes ownership of param (and all its values).

Duplicate parameters have their values merged, so that all parameter names in self are unique. Values are also merged so that uniqueness is preserved.

add_param_with_value(param, value)
Parameters:

Appends value to param, then prepends param to self. This takes ownership of param, but not of value.

This is a convenience method for EBookContacts.VCardAttributeParam.add_value() and EBookContacts.VCardAttribute.add_param().

add_value(value)
Parameters:

value (str) – a string value

Appends value to self's list of values.

add_value_decoded(value, len)
Parameters:
  • value (str) – an encoded value

  • len (int) – the length of the encoded value, in bytes

Encodes value according to the encoding used for self, and appends it to self's list of values.

This should only be used if the EBookContacts.VCardAttribute has a non-raw encoding (i.e. if it’s encoded in base-64 or quoted-printable encoding).

copy()
Returns:

A new EBookContacts.VCardAttribute identical to self.

Return type:

EBookContacts.VCardAttribute

Makes a copy of self.

free()

Frees an attribute, its values and its parameters.

get_group()
Returns:

The attribute’s group name, or None.

Return type:

str or None

Gets the group name of self.

get_name()
Returns:

The attribute’s name.

Return type:

str

Gets the name of self.

get_param(name)
Parameters:

name (str) – a parameter name

Returns:

A list of string elements representing the parameter’s values, or None.

Return type:

[str] or None

Gets the list of values for the paramater name from self. The list and its contents are owned by self, and must not be freed. If no parameter with the given name exists, None is returned.

get_params()
Returns:

A list of elements of type EBookContacts.VCardAttributeParam.

Return type:

[EBookContacts.VCardAttributeParam]

Gets the list of parameters (of type EBookContacts.VCardAttributeParam) from self. The list and its contents are owned by self, and must not be freed.

get_value()
Returns:

A newly allocated string representing the value, or None if the attribute has no value.

Return type:

str or None

Gets the value of a single-valued EBookContacts.VCardAttribute, self.

For example, for a FN (full name) attribute, this will return the contact’s full name as a single string.

This will print a warning if called on an EBookContacts.VCardAttribute which is not single-valued (i.e. for which EBookContacts.VCardAttribute.is_single_valued() returns False). Use EBookContacts.VCardAttribute.get_values() in such cases instead.

get_value_decoded()
Returns:

A newly allocated GLib.String representing the value, or None if the attribute has no value.

Return type:

GLib.String or None

Gets the value of a single-valued EBookContacts.VCardAttribute, self, decoding it if necessary according to the encoding given in the vCard’s

ENCODING attribute. This will print a warning if called on an EBookContacts.VCardAttribute which is not single-valued (i.e. for which EBookContacts.VCardAttribute.is_single_valued() returns False). Use EBookContacts.VCardAttribute.get_values_decoded() in such cases instead.

get_values()
Returns:

A list of string values. They will all be non-None, but may be empty strings. The list itself may be empty.

Return type:

[str]

Gets the ordered list of values from self. The list and its contents are owned by self, and must not be freed.

For example, for an ADR (postal address) attribute, this will return the components of the postal address.

This may be called on a single-valued attribute (i.e. one for which EBookContacts.VCardAttribute.is_single_valued() returns True) and will return a one-element list in that case. Alternatively, use EBookContacts.VCardAttribute.get_value() in such cases.

get_values_decoded()
Returns:

A list of values of type GLib.String.

Return type:

[GLib.String]

Gets the ordered list of values from self, decoding them if necessary according to the encoding given in the vCard’s

ENCODING attribute. The list and its contents are owned by self, and must not be freed.

This may be called on a single-valued attribute (i.e. one for which EBookContacts.VCardAttribute.is_single_valued() returns True) and will return a one-element list in that case. Alternatively, use EBookContacts.VCardAttribute.get_value_decoded() in such cases.

has_type(typestr)
Parameters:

typestr (str) – a string representing the type

Returns:

True if such a parameter exists, False otherwise.

Return type:

bool

Checks if self has an EBookContacts.VCardAttributeParam with name EBookContacts.EVC_TYPE and typestr as one of its values.

For example, for the vCard attribute:

TEL;TYPE=WORK,VOICE:(111) 555-1212

the following holds true:

g_assert_true (e_vcard_attribute_has_type (attr, "WORK") == TRUE);
g_assert_true (e_vcard_attribute_has_type (attr, "voice") == TRUE);
g_assert_true (e_vcard_attribute_has_type (attr, "HOME") == FALSE);

Comparisons against typestr are case-insensitive.

is_single_valued()
Returns:

True if the attribute has exactly one value, False otherwise.

Return type:

bool

Checks if self has a single value.

remove_param(param_name)
Parameters:

param_name (str) – a parameter name

Removes and frees parameter param_name from the attribute self. Parameter names are guaranteed to be unique, so self is guaranteed to have no parameters named param_name after this function returns.

New in version 1.12.

remove_param_value(param_name, s)
Parameters:
  • param_name (str) – a parameter name

  • s (str) – a value

Removes the value s from the parameter param_name on the attribute self. If s was the only value for parameter param_name, that parameter is removed entirely from self and freed.

remove_params()

Removes and frees all parameters from self.

This also resets the EBookContacts.VCardAttribute's encoding back to raw.

remove_value(s)
Parameters:

s (str) – a value to remove

Removes value s from the value list in self. The value s is not freed.

remove_values()

Removes and frees all values from self.