dbus-fast 2.45.0__cp39-cp39-musllinux_1_2_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. dbus_fast/__init__.py +82 -0
  2. dbus_fast/__version__.py +10 -0
  3. dbus_fast/_private/__init__.py +1 -0
  4. dbus_fast/_private/_cython_compat.py +14 -0
  5. dbus_fast/_private/address.cpython-39-aarch64-linux-gnu.so +0 -0
  6. dbus_fast/_private/address.pxd +15 -0
  7. dbus_fast/_private/address.py +117 -0
  8. dbus_fast/_private/constants.py +20 -0
  9. dbus_fast/_private/marshaller.cpython-39-aarch64-linux-gnu.so +0 -0
  10. dbus_fast/_private/marshaller.pxd +110 -0
  11. dbus_fast/_private/marshaller.py +228 -0
  12. dbus_fast/_private/unmarshaller.cpython-39-aarch64-linux-gnu.so +0 -0
  13. dbus_fast/_private/unmarshaller.pxd +261 -0
  14. dbus_fast/_private/unmarshaller.py +902 -0
  15. dbus_fast/_private/util.py +176 -0
  16. dbus_fast/aio/__init__.py +5 -0
  17. dbus_fast/aio/message_bus.py +578 -0
  18. dbus_fast/aio/message_reader.cpython-39-aarch64-linux-gnu.so +0 -0
  19. dbus_fast/aio/message_reader.pxd +13 -0
  20. dbus_fast/aio/message_reader.py +49 -0
  21. dbus_fast/aio/proxy_object.py +207 -0
  22. dbus_fast/auth.py +126 -0
  23. dbus_fast/constants.py +152 -0
  24. dbus_fast/errors.py +84 -0
  25. dbus_fast/glib/__init__.py +3 -0
  26. dbus_fast/glib/message_bus.py +515 -0
  27. dbus_fast/glib/proxy_object.py +319 -0
  28. dbus_fast/introspection.py +683 -0
  29. dbus_fast/message.cpython-39-aarch64-linux-gnu.so +0 -0
  30. dbus_fast/message.pxd +76 -0
  31. dbus_fast/message.py +387 -0
  32. dbus_fast/message_bus.cpython-39-aarch64-linux-gnu.so +0 -0
  33. dbus_fast/message_bus.pxd +75 -0
  34. dbus_fast/message_bus.py +1310 -0
  35. dbus_fast/proxy_object.py +358 -0
  36. dbus_fast/py.typed +0 -0
  37. dbus_fast/send_reply.py +61 -0
  38. dbus_fast/service.cpython-39-aarch64-linux-gnu.so +0 -0
  39. dbus_fast/service.pxd +50 -0
  40. dbus_fast/service.py +682 -0
  41. dbus_fast/signature.cpython-39-aarch64-linux-gnu.so +0 -0
  42. dbus_fast/signature.pxd +31 -0
  43. dbus_fast/signature.py +481 -0
  44. dbus_fast/unpack.cpython-39-aarch64-linux-gnu.so +0 -0
  45. dbus_fast/unpack.pxd +13 -0
  46. dbus_fast/unpack.py +24 -0
  47. dbus_fast/validators.py +199 -0
  48. dbus_fast-2.45.0.dist-info/METADATA +263 -0
  49. dbus_fast-2.45.0.dist-info/RECORD +51 -0
  50. dbus_fast-2.45.0.dist-info/WHEEL +4 -0
  51. dbus_fast-2.45.0.dist-info/licenses/LICENSE +22 -0
@@ -0,0 +1,176 @@
1
+ from __future__ import annotations
2
+
3
+ import ast
4
+ import inspect
5
+ from typing import Any, Callable
6
+
7
+ from ..signature import SignatureTree, SignatureType, Variant, get_signature_tree
8
+
9
+
10
+ def signature_contains_type(
11
+ signature: str | SignatureTree, body: list[Any], token: str
12
+ ) -> bool:
13
+ """For a given signature and body, check to see if it contains any members
14
+ with the given token"""
15
+ if type(signature) is str:
16
+ signature = get_signature_tree(signature)
17
+
18
+ queue = list(signature.types) # type: ignore[union-attr]
19
+ contains_variants = False
20
+
21
+ while True:
22
+ if not queue:
23
+ break
24
+ st = queue.pop()
25
+ if st.token == token:
26
+ return True
27
+ if st.token == "v":
28
+ contains_variants = True
29
+ queue.extend(st.children)
30
+
31
+ if not contains_variants:
32
+ return False
33
+
34
+ for member in body:
35
+ queue.append(member)
36
+
37
+ while True:
38
+ if not queue:
39
+ return False
40
+ member = queue.pop()
41
+ if type(member) is Variant and signature_contains_type(
42
+ member.signature, [member.value], token
43
+ ):
44
+ return True
45
+ if type(member) is list:
46
+ queue.extend(member)
47
+ elif type(member) is dict:
48
+ queue.extend(member.values())
49
+
50
+
51
+ def replace_fds_with_idx(
52
+ signature: str | SignatureTree, body: list[Any]
53
+ ) -> tuple[list[Any], list[int]]:
54
+ """Take the high level body format and convert it into the low level body
55
+ format. Type 'h' refers directly to the fd in the body. Replace that with
56
+ an index and return the corresponding list of unix fds that can be set on
57
+ the Message"""
58
+ if type(signature) is str:
59
+ signature = get_signature_tree(signature)
60
+
61
+ if not signature_contains_type(signature, body, "h"):
62
+ return body, []
63
+
64
+ unix_fds: list[Any] = []
65
+
66
+ def _replace(fd: Any) -> int:
67
+ try:
68
+ return unix_fds.index(fd)
69
+ except ValueError:
70
+ unix_fds.append(fd)
71
+ return len(unix_fds) - 1
72
+
73
+ _replace_fds(body, signature.types, _replace) # type: ignore[union-attr]
74
+
75
+ return body, unix_fds
76
+
77
+
78
+ def replace_idx_with_fds(
79
+ signature: str | SignatureTree, body: list[Any], unix_fds: list[Any]
80
+ ) -> list[Any]:
81
+ """Take the low level body format and return the high level body format.
82
+ Type 'h' refers to an index in the unix_fds array. Replace those with the
83
+ actual file descriptor or `None` if one does not exist."""
84
+ if type(signature) is str:
85
+ signature = get_signature_tree(signature)
86
+
87
+ if not signature_contains_type(signature, body, "h"):
88
+ return body
89
+
90
+ def _replace(idx: int) -> Any:
91
+ try:
92
+ return unix_fds[idx]
93
+ except IndexError:
94
+ return None
95
+
96
+ _replace_fds(body, signature.types, _replace) # type: ignore[union-attr]
97
+
98
+ return body
99
+
100
+
101
+ def parse_annotation(annotation: str) -> str:
102
+ """
103
+ Because of PEP 563, if `from __future__ import annotations` is used in code
104
+ or on Python version >=3.10 where this is the default, return annotations
105
+ from the `inspect` module will return annotations as "forward definitions".
106
+ In this case, we must eval the result which we do only when given a string
107
+ constant.
108
+ """
109
+
110
+ def raise_value_error() -> None:
111
+ raise ValueError(
112
+ f"service annotations must be a string constant (got {annotation})"
113
+ )
114
+
115
+ if not annotation or annotation is inspect.Signature.empty:
116
+ return ""
117
+ if type(annotation) is not str:
118
+ raise_value_error()
119
+ try:
120
+ body = ast.parse(annotation).body
121
+ if len(body) == 1 and type(body[0].value) is ast.Constant: # type: ignore[attr-defined]
122
+ if type(body[0].value.value) is not str: # type: ignore[attr-defined]
123
+ raise_value_error()
124
+ return body[0].value.value # type: ignore[attr-defined]
125
+ except SyntaxError:
126
+ pass
127
+
128
+ return annotation
129
+
130
+
131
+ def _replace_fds(
132
+ body_obj: dict[Any, Any] | list[Any],
133
+ children: list[SignatureType],
134
+ replace_fn: Callable[[Any], Any],
135
+ ) -> None:
136
+ """Replace any type 'h' with the value returned by replace_fn() given the
137
+ value of the fd field. This is used by the high level interfaces which
138
+ allow type 'h' to be the fd directly instead of an index in an external
139
+ array such as in the spec."""
140
+ for index, st in enumerate(children):
141
+ if not any(sig in st.signature for sig in "hv"):
142
+ continue
143
+ if st.signature == "h":
144
+ body_obj[index] = replace_fn(body_obj[index])
145
+ elif st.token == "a":
146
+ if st.children[0].token == "{":
147
+ _replace_fds(body_obj[index], st.children, replace_fn)
148
+ else:
149
+ for i, child in enumerate(body_obj[index]):
150
+ if st.signature == "ah":
151
+ body_obj[index][i] = replace_fn(child)
152
+ else:
153
+ _replace_fds([child], st.children, replace_fn)
154
+ elif st.token in "(":
155
+ _replace_fds(body_obj[index], st.children, replace_fn)
156
+ elif st.token in "{":
157
+ for key, value in list(body_obj.items()): # type: ignore[union-attr]
158
+ body_obj.pop(key)
159
+ if st.children[0].signature == "h":
160
+ key = replace_fn(key)
161
+ if st.children[1].signature == "h":
162
+ value = replace_fn(value)
163
+ else:
164
+ _replace_fds([value], [st.children[1]], replace_fn)
165
+ body_obj[key] = value
166
+
167
+ elif st.signature == "v":
168
+ if body_obj[index].signature == "h":
169
+ body_obj[index].value = replace_fn(body_obj[index].value)
170
+ else:
171
+ _replace_fds(
172
+ [body_obj[index].value], [body_obj[index].type], replace_fn
173
+ )
174
+
175
+ elif st.children:
176
+ _replace_fds(body_obj[index], st.children, replace_fn)
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ from .message_bus import MessageBus as MessageBus
4
+ from .proxy_object import ProxyInterface as ProxyInterface
5
+ from .proxy_object import ProxyObject as ProxyObject