Skip to content

Commit 40dc182

Browse files
committed
python: move get_dc_event_name() to events
1 parent 3cf1aad commit 40dc182

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- jsonrpc: add `is_broadcast` property to `ChatListItemFetchResult` #3584
2424
- jsonrpc: add `was_seen_recently` property to `ChatListItemFetchResult`, `FullChat` and `Contact` #3584
2525
- jsonrpc: add `webxdc_info` property to `Message` #3588
26+
- python: move `get_dc_event_name()` from `deltachat` to `deltachat.events` #3564
2627

2728
### Changes
2829
- order contact lists by "last seen";

python/src/deltachat/__init__.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from pkg_resources import DistributionNotFound, get_distribution
44

5-
from . import capi, const, events, hookspec # noqa
5+
from . import capi, events, hookspec # noqa
66
from .account import Account, get_core_info # noqa
77
from .capi import ffi # noqa
88
from .chat import Chat # noqa
@@ -17,14 +17,6 @@
1717
__version__ = "0.0.0.dev0-unknown"
1818

1919

20-
def get_dc_event_name(integer, _DC_EVENTNAME_MAP={}):
21-
if not _DC_EVENTNAME_MAP:
22-
for name in dir(const):
23-
if name.startswith("DC_EVENT_"):
24-
_DC_EVENTNAME_MAP[getattr(const, name)] = name
25-
return _DC_EVENTNAME_MAP[integer]
26-
27-
2820
def register_global_plugin(plugin):
2921
"""Register a global plugin which implements one or more
3022
of the :class:`deltachat.hookspec.Global` hooks.

python/src/deltachat/events.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@
88
from contextlib import contextmanager
99
from queue import Empty, Queue
1010

11-
import deltachat
12-
11+
from . import const
1312
from .capi import ffi, lib
1413
from .cutil import from_optional_dc_charpointer
1514
from .hookspec import account_hookimpl
1615
from .message import map_system_message
1716

1817

18+
def get_dc_event_name(integer, _DC_EVENTNAME_MAP={}):
19+
if not _DC_EVENTNAME_MAP:
20+
for name in dir(const):
21+
if name.startswith("DC_EVENT_"):
22+
_DC_EVENTNAME_MAP[getattr(const, name)] = name
23+
return _DC_EVENTNAME_MAP[integer]
24+
25+
1926
class FFIEvent:
2027
def __init__(self, name: str, data1, data2):
2128
self.name = name
@@ -239,7 +246,7 @@ def _inner_run(self):
239246
data1 = lib.dc_event_get_data1_int(event)
240247
# the following code relates to the deltachat/_build.py's helper
241248
# function which provides us signature info of an event call
242-
evt_name = deltachat.get_dc_event_name(evt)
249+
evt_name = get_dc_event_name(evt)
243250
if lib.dc_event_has_string_data(evt):
244251
data2 = from_optional_dc_charpointer(lib.dc_event_get_data2_str(event))
245252
else:

0 commit comments

Comments
 (0)