stinger-python-utils 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.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.
@@ -1,15 +1,13 @@
1
-
2
1
  from pyqttier.message import Message
3
2
  from pydantic import BaseModel
4
3
  from typing import Union, Optional
5
4
  import uuid
6
5
 
6
+
7
7
  class MessageCreator:
8
8
 
9
9
  @classmethod
10
- def signal_message(
11
- cls, topic: str, payload: BaseModel
12
- ) -> Message:
10
+ def signal_message(cls, topic: str, payload: BaseModel) -> Message:
13
11
  return Message(
14
12
  topic=topic,
15
13
  payload=payload.model_dump_json(by_alias=True).encode("utf-8"),
@@ -62,14 +60,19 @@ class MessageCreator:
62
60
  def response_message(
63
61
  cls,
64
62
  response_topic: str,
65
- response_obj: BaseModel|str|bytes,
63
+ response_obj: BaseModel | str | bytes,
66
64
  return_code: int,
67
65
  correlation_id: Union[str, bytes],
68
66
  ) -> Message:
69
67
  """
70
68
  This could be used for a successful response to a request.
71
69
  """
72
- payload = response_obj.model_dump_json(by_alias=True).encode("utf-8") if isinstance(response_obj, BaseModel) else response_obj
70
+ if isinstance(response_obj, BaseModel):
71
+ payload = response_obj.model_dump_json(by_alias=True).encode("utf-8")
72
+ elif isinstance(response_obj, str):
73
+ payload = response_obj.encode("utf-8")
74
+ else:
75
+ payload = response_obj
73
76
  msg_obj = Message(
74
77
  topic=response_topic,
75
78
  payload=payload,
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stinger-python-utils
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
+ Summary: Common utilities for Stinger Python services.
4
5
  License-Expression: MIT
5
6
  License-File: LICENSE
6
7
  Requires-Python: >=3.7
7
8
  Requires-Dist: pydantic>=2.5.3
8
- Requires-Dist: pyqttier>=0.1.6
9
- Provides-Extra: dev
9
+ Requires-Dist: pyqttier>=0.2.0
10
10
  Description-Content-Type: text/markdown
11
11
 
12
12
  # stinger-python-utils
@@ -0,0 +1,7 @@
1
+ stinger_python_utils/__init__.py,sha256=IjHRV0k2DNwvFrEHebmsXiBvmITE8nQUnsR07h9tVkU,7
2
+ stinger_python_utils/message_creator.py,sha256=ZR4FOhkmJ5R_X5QS-c-QAIpcN-7htIOiHtO40QUS35Y,6071
3
+ stinger_python_utils/return_codes.py,sha256=AAwshvHu3SBoctwMX35k3j666J4a7DQ3V8AnR7QBjC8,5114
4
+ stinger_python_utils-0.1.2.dist-info/METADATA,sha256=LxgDU_LYLjt9F5FMBkIsiK_XR61DL1tOEVOxI0glX78,364
5
+ stinger_python_utils-0.1.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ stinger_python_utils-0.1.2.dist-info/licenses/LICENSE,sha256=_T-8ExmblJbhv-1AxC6XDVEHg1JdJA-126NvRiMqS-I,1070
7
+ stinger_python_utils-0.1.2.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- stinger_python_utils/__init__.py,sha256=IjHRV0k2DNwvFrEHebmsXiBvmITE8nQUnsR07h9tVkU,7
2
- stinger_python_utils/message_creator,sha256=Tho68dvdCje0a4DELlbzH2C9fhEqg7s2TkdBDohoON0,5942
3
- stinger_python_utils/return_codes.py,sha256=AAwshvHu3SBoctwMX35k3j666J4a7DQ3V8AnR7QBjC8,5114
4
- stinger_python_utils-0.1.0.dist-info/METADATA,sha256=zHjbeGUJso2nf_tXJjT5aoJffVNKzuK2dDqXlY6Iv00,329
5
- stinger_python_utils-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
- stinger_python_utils-0.1.0.dist-info/licenses/LICENSE,sha256=_T-8ExmblJbhv-1AxC6XDVEHg1JdJA-126NvRiMqS-I,1070
7
- stinger_python_utils-0.1.0.dist-info/RECORD,,