diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e8a1b674..d12027d49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - jsonrpc: add `is_broadcast` property to `ChatListItemFetchResult` #3584 - jsonrpc: add `was_seen_recently` property to `ChatListItemFetchResult`, `FullChat` and `Contact` #3584 - jsonrpc: add `webxdc_info` property to `Message` #3588 +- python: move `get_dc_event_name()` from `deltachat` to `deltachat.events` #3564 ### Changes - order contact lists by "last seen"; diff --git a/python/src/deltachat/__init__.py b/python/src/deltachat/__init__.py index 45f1b8b2e..8a15ac942 100644 --- a/python/src/deltachat/__init__.py +++ b/python/src/deltachat/__init__.py @@ -2,7 +2,7 @@ import sys from pkg_resources import DistributionNotFound, get_distribution -from . import capi, const, events, hookspec # noqa +from . import capi, events, hookspec # noqa from .account import Account, get_core_info # noqa from .capi import ffi # noqa from .chat import Chat # noqa @@ -17,14 +17,6 @@ except DistributionNotFound: __version__ = "0.0.0.dev0-unknown" -def get_dc_event_name(integer, _DC_EVENTNAME_MAP={}): - if not _DC_EVENTNAME_MAP: - for name in dir(const): - if name.startswith("DC_EVENT_"): - _DC_EVENTNAME_MAP[getattr(const, name)] = name - return _DC_EVENTNAME_MAP[integer] - - def register_global_plugin(plugin): """Register a global plugin which implements one or more of the :class:`deltachat.hookspec.Global` hooks. diff --git a/python/src/deltachat/events.py b/python/src/deltachat/events.py index 3a14aad58..ace7a8b88 100644 --- a/python/src/deltachat/events.py +++ b/python/src/deltachat/events.py @@ -8,14 +8,21 @@ import traceback from contextlib import contextmanager from queue import Empty, Queue -import deltachat - +from . import const from .capi import ffi, lib from .cutil import from_optional_dc_charpointer from .hookspec import account_hookimpl from .message import map_system_message +def get_dc_event_name(integer, _DC_EVENTNAME_MAP={}): + if not _DC_EVENTNAME_MAP: + for name in dir(const): + if name.startswith("DC_EVENT_"): + _DC_EVENTNAME_MAP[getattr(const, name)] = name + return _DC_EVENTNAME_MAP[integer] + + class FFIEvent: def __init__(self, name: str, data1, data2): self.name = name @@ -239,7 +246,7 @@ class EventThread(threading.Thread): data1 = lib.dc_event_get_data1_int(event) # the following code relates to the deltachat/_build.py's helper # function which provides us signature info of an event call - evt_name = deltachat.get_dc_event_name(evt) + evt_name = get_dc_event_name(evt) if lib.dc_event_has_string_data(evt): data2 = from_optional_dc_charpointer(lib.dc_event_get_data2_str(event)) else: