diff --git a/python/doc/api.rst b/python/doc/api.rst index 4683793c..93fcd228 100644 --- a/python/doc/api.rst +++ b/python/doc/api.rst @@ -6,21 +6,43 @@ high level API reference This API is work in progress and may change in versions prior to 1.0. -.. autosummary:: +- :class:`deltachat.account.Account` (your main entry point, creates the + other classes) +- :class:`deltachat.chatting.Contact` +- :class:`deltachat.chatting.Chat` +- :class:`deltachat.chatting.Message` +- :class:`deltachat.chatting.MessageState` - deltachat.account - deltachat.chatting +Account +------- -account module --------------- - -.. automodule:: deltachat.account +.. autoclass:: deltachat.account.Account :members: -chatting module ---------------- +Contact +------- -.. automodule:: deltachat.chatting +.. autoclass:: deltachat.chatting.Contact :members: +Chat +---- + +.. autoclass:: deltachat.chatting.Chat + :members: + +Message +------- + +.. autoclass:: deltachat.chatting.Message + :members: + + +MessageState +------------ + +.. autoclass:: deltachat.chatting.MessageState + :members: + + diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 44fccad9..e1c5b7d2 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -20,8 +20,9 @@ from .chatting import Contact, Chat, Message class Account(object): - """ An account contains configuration and provides methods - for configuration, contact and chat creation and manipulation. + """ Each account is tied to a sqlite database file which is fully managed + by the underlying deltachat c-library. All public Account methods are + meant to be memory-safe and return memory-safe objects. """ def __init__(self, db_path, logid=None): @@ -86,7 +87,7 @@ class Account(object): self.check_is_configured() return Contact(self._dc_context, lib.DC_CONTACT_ID_SELF) - def create_contact(self, email, name=ffi.NULL): + def create_contact(self, email, name=None): """ create a (new) Contact. If there already is a Contact with that e-mail address, it is unblocked and its name is updated. @@ -100,7 +101,7 @@ class Account(object): contact_id = lib.dc_create_contact(self._dc_context.p, name, email) return Contact(self._dc_context, contact_id) - def get_contacts(self, query=ffi.NULL, with_self=False, only_verified=False): + def get_contacts(self, query=None, with_self=False, only_verified=False): """ get a (filtered) list of contacts. :param query: if a string is specified, only return contacts diff --git a/python/src/deltachat/cutil.py b/python/src/deltachat/cutil.py index fa8da654..bf2cf1c6 100644 --- a/python/src/deltachat/cutil.py +++ b/python/src/deltachat/cutil.py @@ -3,8 +3,8 @@ from .capi import ffi def convert_to_bytes_utf8(obj): - if obj == ffi.NULL: - return obj + if obj == ffi.NULL or obj is None: + return ffi.NULL if not isinstance(obj, bytes): return obj.encode("utf8") return obj