Skip to content

Commit 87aefaa

Browse files
committed
Split sdbus.utils package
Move current parsing utilities to `sdbus.utils.parse` subpackage. For backwards compatibility import them to the `__init__.py`. This allows better package separation in the future.
1 parent 266fca5 commit 87aefaa

File tree

6 files changed

+52
-13
lines changed

6 files changed

+52
-13
lines changed

docs/asyncio_api.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Classes
7575

7676
Signal when one of the objects properties changes.
7777

78-
:py:func:`sdbus.utils.parse_properties_changed` can be used to transform
78+
:py:func:`sdbus.utils.parse.parse_properties_changed` can be used to transform
7979
this signal data in to an easier to work with dictionary.
8080

8181
Signal data is:
@@ -192,7 +192,7 @@ Classes
192192

193193
Get the objects this object manager in managing.
194194

195-
:py:func:`sdbus.utils.parse_get_managed_objects` can be used
195+
:py:func:`sdbus.utils.parse.parse_get_managed_objects` can be used
196196
to make returned data easier to work with.
197197

198198
:return:
@@ -209,7 +209,7 @@ Classes
209209
Signal when a new object is added or and existing object
210210
gains a new interface.
211211

212-
:py:func:`sdbus.utils.parse_interfaces_added` can be used
212+
:py:func:`sdbus.utils.parse.parse_interfaces_added` can be used
213213
to make signal data easier to work with.
214214

215215
Signal data is:
@@ -226,7 +226,7 @@ Classes
226226
Signal when existing object or and interface of
227227
existing object is removed.
228228

229-
:py:func:`sdbus.utils.parse_interfaces_removed` can be used
229+
:py:func:`sdbus.utils.parse.parse_interfaces_removed` can be used
230230
to make signal data easier to work with.
231231

232232
Signal data is:

docs/utils.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Utilities
44
Parsing utilities
55
+++++++++++++++++
66

7-
.. py:currentmodule:: sdbus.utils
7+
Parse unweildy D-Bus structures in to Python native objects and names.
8+
Available under ``sdbus.utils.parse`` subpackage.
9+
10+
.. py:currentmodule:: sdbus.utils.parse
811
912
.. py:function:: parse_properties_changed(interface, properties_changed_data, on_unknown_member='error')
1013

setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,12 @@ def get_link_arguments() -> List[str]:
118118
'Programming Language :: Python :: 3 :: Only',
119119
'Topic :: Software Development :: Libraries :: Python Modules',
120120
],
121-
packages=['sdbus',
122-
# 'sdbus_async', 'sdbus_block',
123-
'sdbus_async.dbus_daemon', 'sdbus_block.dbus_daemon',
124-
],
121+
packages=[
122+
'sdbus',
123+
'sdbus.utils',
124+
'sdbus_async.dbus_daemon',
125+
'sdbus_block.dbus_daemon',
126+
],
125127
package_dir={
126128
'sdbus': 'src/sdbus',
127129
'sdbus_async.dbus_daemon': 'src/sdbus_async/dbus_daemon',

src/sdbus/utils/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
# Copyright (C) 2024 igo95862
4+
5+
# This file is part of python-sdbus
6+
7+
# This library is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU Lesser General Public
9+
# License as published by the Free Software Foundation; either
10+
# version 2.1 of the License, or (at your option) any later version.
11+
12+
# This library is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# Lesser General Public License for more details.
16+
17+
# You should have received a copy of the GNU Lesser General Public
18+
# License along with this library; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
from __future__ import annotations
21+
22+
from .parse import (
23+
parse_get_managed_objects,
24+
parse_interfaces_added,
25+
parse_interfaces_removed,
26+
parse_properties_changed,
27+
)
28+
29+
__all__ = (
30+
"parse_get_managed_objects",
31+
"parse_interfaces_added",
32+
"parse_interfaces_removed",
33+
"parse_properties_changed",
34+
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
from typing import TYPE_CHECKING
2323

24-
from .dbus_common_funcs import _parse_properties_vardict
25-
from .dbus_proxy_async_interface_base import (
24+
from ..dbus_common_funcs import _parse_properties_vardict
25+
from ..dbus_proxy_async_interface_base import (
2626
DBUS_CLASS_TO_META,
2727
DBUS_INTERFACE_NAME_TO_CLASS,
2828
DbusInterfaceBaseAsync,
@@ -42,7 +42,7 @@
4242
Union,
4343
)
4444

45-
from .dbus_proxy_async_interfaces import DBUS_PROPERTIES_CHANGED_TYPING
45+
from ..dbus_proxy_async_interfaces import DBUS_PROPERTIES_CHANGED_TYPING
4646

4747
InterfacesInputElements = Union[
4848
DbusInterfaceBaseAsync,

test/test_sdbus_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
DbusPropertyEmitsChangeFlag,
4141
)
4242
from sdbus.unittest import IsolatedDbusTestCase
43-
from sdbus.utils import parse_properties_changed
43+
from sdbus.utils.parse import parse_properties_changed
4444

4545
from sdbus import (
4646
DbusInterfaceCommonAsync,

0 commit comments

Comments
 (0)