satori-python 1.3.4__tar.gz → 1.3.6__tar.gz
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.
- {satori_python-1.3.4 → satori_python-1.3.6}/PKG-INFO +1 -1
- {satori_python-1.3.4 → satori_python-1.3.6}/pyproject.toml +1 -1
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/__init__.py +1 -1
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/element.py +28 -12
- {satori_python-1.3.4 → satori_python-1.3.6}/LICENSE +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/README.md +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/_vendor/fleep.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/__init__.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/account.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/account.pyi +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/config.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/network/__init__.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/network/base.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/network/util.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/network/webhook.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/network/websocket.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/client/protocol.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/const.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/event.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/exception.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/model.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/parser.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/py.typed +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/server/__init__.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/server/adapter.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/server/connection.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/server/formdata.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/server/model.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/server/route.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/server/utils.py +0 -0
- {satori_python-1.3.4 → satori_python-1.3.6}/src/satori/utils.py +0 -0
|
@@ -124,10 +124,12 @@ class Element:
|
|
|
124
124
|
return self.dumps()
|
|
125
125
|
|
|
126
126
|
def __repr__(self) -> str:
|
|
127
|
+
if not self._attrs:
|
|
128
|
+
self._attrs = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
|
|
127
129
|
args = {**self._attrs}
|
|
128
130
|
elem = f"{self.__class__.__name__}(" + ", ".join(f"{k}={v!r}" for k, v in args.items())
|
|
129
131
|
if self._children:
|
|
130
|
-
elem += ",
|
|
132
|
+
elem += ", [" + ", ".join(repr(i) for i in self._children) + "]"
|
|
131
133
|
return elem + ")"
|
|
132
134
|
|
|
133
135
|
def __call__(self, *content: "str | Element"):
|
|
@@ -255,7 +257,6 @@ class Link(Element):
|
|
|
255
257
|
class Resource(Element):
|
|
256
258
|
src: str
|
|
257
259
|
title: str | None = None
|
|
258
|
-
extra: InitVar[dict[str, Any] | None] = None
|
|
259
260
|
cache: bool | None = None
|
|
260
261
|
timeout: int | None = None
|
|
261
262
|
|
|
@@ -269,14 +270,15 @@ class Resource(Element):
|
|
|
269
270
|
raw: bytes | BytesIO | None = None,
|
|
270
271
|
mime: str | None = None,
|
|
271
272
|
name: str | None = None,
|
|
273
|
+
width: int | None = None,
|
|
274
|
+
height: int | None = None,
|
|
272
275
|
duration: float | None = None,
|
|
273
276
|
poster: str | None = None,
|
|
274
|
-
extra: dict[str, Any] | None = None,
|
|
275
277
|
cache: bool | None = None,
|
|
276
278
|
timeout: int | None = None,
|
|
277
279
|
**kwargs,
|
|
278
280
|
) -> Self:
|
|
279
|
-
data: dict[str, Any] = {
|
|
281
|
+
data: dict[str, Any] = {**kwargs}
|
|
280
282
|
if url is not None:
|
|
281
283
|
data |= {"src": url}
|
|
282
284
|
elif path:
|
|
@@ -294,6 +296,10 @@ class Resource(Element):
|
|
|
294
296
|
raise ValueError(f"{cls} need at least one of url, path and raw")
|
|
295
297
|
if name is not None:
|
|
296
298
|
data["title"] = name
|
|
299
|
+
if width is not None and cls in (Image, Video):
|
|
300
|
+
data["width"] = width
|
|
301
|
+
if height is not None and cls in (Image, Video):
|
|
302
|
+
data["height"] = height
|
|
297
303
|
if duration is not None and cls is Audio:
|
|
298
304
|
data["duration"] = duration
|
|
299
305
|
if poster is not None and cls in (Video, Audio, File):
|
|
@@ -302,11 +308,7 @@ class Resource(Element):
|
|
|
302
308
|
data["cache"] = cache
|
|
303
309
|
if timeout is not None:
|
|
304
310
|
data["timeout"] = timeout
|
|
305
|
-
return cls(
|
|
306
|
-
|
|
307
|
-
def __post_init__(self, extra: dict[str, Any] | None = None):
|
|
308
|
-
if extra:
|
|
309
|
-
self._attrs.update(extra)
|
|
311
|
+
return cls.unpack(data)
|
|
310
312
|
|
|
311
313
|
|
|
312
314
|
@dataclass(repr=False)
|
|
@@ -487,7 +489,7 @@ class Message(Element):
|
|
|
487
489
|
self,
|
|
488
490
|
id: str | None = None,
|
|
489
491
|
forward: bool | None = None,
|
|
490
|
-
content:
|
|
492
|
+
content: Sequence[str | Element] | None = None,
|
|
491
493
|
):
|
|
492
494
|
self.id = id
|
|
493
495
|
self.forward = forward
|
|
@@ -580,7 +582,7 @@ class Custom(Element):
|
|
|
580
582
|
attrs: dict[str, Any] | None = None,
|
|
581
583
|
children: Sequence[str | Element] | None = None,
|
|
582
584
|
):
|
|
583
|
-
self.
|
|
585
|
+
self._type = type
|
|
584
586
|
if not hasattr(self, "_attrs"):
|
|
585
587
|
self._attrs = attrs or {}
|
|
586
588
|
else:
|
|
@@ -593,7 +595,21 @@ class Custom(Element):
|
|
|
593
595
|
@property
|
|
594
596
|
@override
|
|
595
597
|
def tag(self) -> str:
|
|
596
|
-
return self.
|
|
598
|
+
return self._type
|
|
599
|
+
|
|
600
|
+
def __repr__(self) -> str:
|
|
601
|
+
if not self._attrs:
|
|
602
|
+
self._attrs = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
|
|
603
|
+
args = {**self._attrs}
|
|
604
|
+
elem = (
|
|
605
|
+
f"{self.__class__.__name__}({self._type!r}"
|
|
606
|
+
+ ", {"
|
|
607
|
+
+ ", ".join(f"{k!r}: {v!r}" for k, v in args.items())
|
|
608
|
+
+ "}"
|
|
609
|
+
)
|
|
610
|
+
if self._children:
|
|
611
|
+
elem += ", [" + ", ".join(repr(i) for i in self._children) + "]"
|
|
612
|
+
return elem + ")"
|
|
597
613
|
|
|
598
614
|
|
|
599
615
|
@dataclass(repr=False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|