Lib

ReadOnlyList

class contacthub.lib.read_only_list.ReadOnlyList[source]

Bases: list

Read only list for managing list in the entities. This class blocks some possible operations on a regular list

static append(*args, **kwargs)

Raise a new ValueError for blocking forbidden operations.

static extend(*args, **kwargs)

Raise a new ValueError for blocking forbidden operations.

static insert(*args, **kwargs)

Raise a new ValueError for blocking forbidden operations.

static not_implemented(*args, **kwargs)[source]

Raise a new ValueError for blocking forbidden operations.

static pop(*args, **kwargs)

Raise a new ValueError for blocking forbidden operations.

static remove(*args, **kwargs)

Raise a new ValueError for blocking forbidden operations.

static reverse(*args, **kwargs)

Raise a new ValueError for blocking forbidden operations.

PaginatedList

class contacthub.lib.paginated_list.PaginatedList(node, function, entity_class, **kwargs)[source]

Bases: contacthub.lib.read_only_list.ReadOnlyList

next_page()[source]

Retrieve the next page of entities in this PaginatedList

Returns:a PaginatedList containing the next page of entities compared to the current one
previous_page()[source]

Retrieve the previous page of entities in this PaginatedList

Returns:a PaginatedList containing the previous page of entities compared to the current one

utils

class contacthub.lib.utils.DateEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)[source]

Bases: json.encoder.JSONEncoder

Class for JSON encoding datetime and date object.

default(obj)[source]

Serialize the given obj for JSON.

Parameters:obj – the object to serialize
Returns:a string ISO 8601 formatted
contacthub.lib.utils.convert_properties_obj_in_prop(properties, properties_class)[source]

Convert the internal properties of properties_class object in a dictionary.

Parameters:
  • properties – the properties of a properties_class object to convert
  • properties_class – if the internal properties of an object are instance of this class, we assign at the property the internal attributes instead of the object
contacthub.lib.utils.generate_mutation_tracker(old_attributes, new_attributes)[source]

Given old attributes of an entity and the new attributes in a Properties object, this method creates a new dictionary based on the whole old attributes dictionary, with:

  • the attributes in old_attributes updated with the attributes in new_attributes
  • the attributes not in new_attributes (deleted) setted to None
Parameters:
  • old_attributes – The old attributes of an entity for create a mutation tracker dict updated
  • new_attributes – The new attributes of an entity for create a mutation tracker dict updated
Returns:

a dictionary with the mutation between old_attributes and new_attributes

contacthub.lib.utils.get_dictionary_paths(d, main_list)[source]

Set the given main_list with lists containing all the key-paths of a dictionary. For example: The key-paths for this list {a{b:{c:1, d:2}, e:3}} are a,b,c; a,b,d; a,e

Parameters:
  • d – the dictionary for gaining all the depth path
  • main_list – a list for creating al the lists containing the paths of the dictt
contacthub.lib.utils.remove_empty_attributes(body)[source]
contacthub.lib.utils.resolve_mutation_tracker(mutation_tracker)[source]

From a dictionary with comma separated keys (e.g. {‘a.b.c.d’: ‘e’}), creates a new dictionary with nested dictionaries, each of which containing a key taken from comma separated keys. (e.g. {‘a’: {‘b’ {‘c’: {‘d’: ‘e’}}}})

Parameters:mutation_tracker – the dictionary with comma separated keys
Returns:a new dictionary containing nested dictionaries with old comma separated keys