DLMS-SPODES-client 0.19.5__py3-none-any.whl → 0.19.6__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.
@@ -970,7 +970,7 @@ class Client:
970
970
  def set_params(self, field: str, value: str):
971
971
  self.__dict__[field] = eval(value)
972
972
 
973
- async def close(self):
973
+ async def close(self) -> None:
974
974
  """close , media is open"""
975
975
  self.log(logL.DEB, "close")
976
976
  if self.level > OSI.DATA_LINK:
@@ -5,7 +5,7 @@ import re
5
5
  from typing_extensions import deprecated
6
6
  import hashlib
7
7
  from dataclasses import dataclass, field
8
- from typing import Callable, Any, Optional, Protocol, cast, override, Self, Final, Iterable
8
+ from typing import Callable, Any, Optional, Protocol, cast, override, Self, Final, Iterable, TypeVarTuple
9
9
  from itertools import count
10
10
  import datetime
11
11
  import time
@@ -35,7 +35,8 @@ from DLMS_SPODES.firmwares import get_firmware
35
35
  from DLMS_SPODES.cosem_interface_classes.image_transfer import image_transfer_status as i_t_status
36
36
  from DLMSAdapter.main import AdapterException, Adapter, gag
37
37
  from DLMSCommunicationProfile.osi import OSI
38
- from .client import Client, logL, Security, Data, mechanism_id, AcseServiceUser, State
38
+ from .logger import LogLevel as logL
39
+ from .client import Client, Security, Data, mechanism_id, AcseServiceUser, State
39
40
 
40
41
 
41
42
  firm_id_pat = re.compile(b".*(?P<fid>PWRM_M2M_[^_]{1,10}_[^_]{1,10}).+")
@@ -56,7 +57,7 @@ class Base[T: result.Result](Protocol):
56
57
  def copy(self) -> Self: ...
57
58
 
58
59
  @property
59
- def current(self) -> 'Base[T]':
60
+ def current(self) -> 'Base[T] | Self':
60
61
  return self
61
62
 
62
63
  async def run(self, c: Client) -> T | result.Error:
@@ -516,7 +517,7 @@ class List[T: result.Result, U: Base[result.Result]](Subtasks[U], _List[T]):
516
517
  )
517
518
 
518
519
  @property
519
- def current(self) -> 'Base[T]':
520
+ def current(self) -> 'Base[T] | Self':
520
521
  return self.__current
521
522
 
522
523
  def append(self, task: Base[T]):
@@ -546,16 +547,16 @@ class Sequence[*Ts](Subtasks[Base[result.Result]], _Sequence[*Ts]):
546
547
  """for exchange task sequence"""
547
548
  msg: str
548
549
  err_ignore: bool
549
- __current: Base[result.Result]
550
- tasks: Base[*Ts]
550
+ __current: "Base[result.Result] | Sequence[*Ts]"
551
+ tasks: tuple[Base[result.Result], ...]
551
552
 
552
- def __init__(self, *tasks: *Ts, msg: str = "", err_ignore: bool = False):
553
+ def __init__(self, *tasks: Base[result.Result], msg: str = "", err_ignore: bool = False):
553
554
  self.tasks = tasks
554
555
  self.__current = self
555
556
  self.msg = self.__class__.__name__ if msg == "" else msg
556
557
  self.err_ignore = err_ignore
557
558
 
558
- def copy(self) -> Self:
559
+ def copy(self) -> "Sequence[*Ts]":
559
560
  if all((isinstance(t, SimpleCopy) for t in self.tasks)):
560
561
  return self
561
562
  return Sequence(
@@ -565,24 +566,23 @@ class Sequence[*Ts](Subtasks[Base[result.Result]], _Sequence[*Ts]):
565
566
  )
566
567
 
567
568
  @property
568
- def current(self) -> Base[result.Result]:
569
+ def current(self) -> Base[result.Result] | Self:
569
570
  return self.__current
570
571
 
571
572
  async def exchange(self, c: Client) -> result.Sequence[*Ts] | result.Error:
572
- res_: list[*Ts] = [result.NULL] * len(self.tasks)
573
- acc = result.ErrorAccumulator()
574
- for i, t in enumerate(self.tasks):
573
+ res = result.Sequence()
574
+ for t in self.tasks:
575
575
  self.__current = t
576
576
  try:
577
- res_[i] = acc.propagate_err(await t.exchange(c))
577
+ if (
578
+ isinstance(res_one := await t.exchange(c), result.Error)
579
+ and not self.err_ignore
580
+ ):
581
+ return res_one
582
+ res = res.add(res_one)
578
583
  except exc.ResultError as e: # todo: make without except
579
- acc.propagate_err(result.Error.from_e(e, msg=t.msg))
580
- if (
581
- not self.err_ignore
582
- and not acc.is_ok()
583
- ):
584
- return acc.as_error()
585
- return result.Sequence(*res_, err=acc.err)
584
+ res.add(result.Error.from_e(e).with_msg(t.msg))
585
+ return cast("result.Sequence[*Ts]", res)
586
586
 
587
587
 
588
588
  class SetLocalTime(SimpleCopy, OK):
@@ -1713,34 +1713,39 @@ class WriteParDatas(SimpleCopy, _List[result.Ok]):
1713
1713
  @dataclass
1714
1714
  class WriteParTranscript(SimpleCopy, OK):
1715
1715
  """write by ParValues[Transcript]"""
1716
- par_value: ParValues[cdt.Transcript]
1716
+ par: Parameter
1717
+ value: cdt.Transcript
1717
1718
  msg: str = ""
1718
1719
 
1719
1720
  async def exchange(self, c: Client) -> result.Ok | result.Error:
1720
- par, value = self.par_value
1721
- if isinstance((res := await Par2Data(par).exchange(c)), result.Error):
1721
+ if isinstance((res := await Par2Data(self.par).exchange(c)), result.Error):
1722
1722
  return res
1723
1723
  data = copy(res.value)
1724
1724
  if isinstance(data, cdt.Digital):
1725
- s_u = c.objects.par2su(par)
1725
+ s_u = c.objects.par2su(self.par)
1726
1726
  if isinstance(s_u, cdt.ScalUnitType):
1727
- value = int(float(value) * 10 ** -int(s_u.scaler))
1728
- data.set(value)
1727
+ value = int(float(self.value) * 10 ** -int(s_u.scaler))
1728
+ data.set(self.value)
1729
1729
  return await WriteAttribute(
1730
- ln=self.par_value.par.obis,
1731
- index=self.par_value.par.i,
1730
+ ln=self.par.obis,
1731
+ index=self.par.i,
1732
1732
  value=data.encoding
1733
1733
  ).exchange(c)
1734
1734
 
1735
1735
 
1736
+ Ts = TypeVarTuple("Ts")
1737
+
1738
+
1736
1739
  @dataclass
1737
- class WriteParTranscripts(SimpleCopy, Base):
1740
+ class WriteParTranscripts(SimpleCopy, Sequence[*Ts]):
1738
1741
  """write by ParValues[Transcript] list"""
1739
- par_values: Final[list[ParValues[cdt.Transcript]]]
1742
+ par_values: list[ParValues[cdt.Transcript]]
1740
1743
  msg: str = ""
1741
1744
 
1742
- async def exchange(self, c: Client) -> result.List:
1743
- res = result.List()
1745
+ async def exchange(self, c: Client) -> result.Sequence[*Ts] | result.Error:
1746
+ res = result.Sequence()
1744
1747
  for par_value in self.par_values:
1745
- WriteParTranscript(par_value)
1748
+ if isinstance(res_one := await WriteParTranscript(*par_value).exchange(c), result.Error):
1749
+ return res_one
1750
+ res = res.add(res_one)
1746
1751
  return res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DLMS_SPODES_client
3
- Version: 0.19.5
3
+ Version: 0.19.6
4
4
  Summary: dlms-spodes
5
5
  Author-email: Serj Kotilevski <youserj@outlook.com>
6
6
  Project-URL: Source, https://github.com/youserj/SPODESclient_prj
@@ -1,12 +1,12 @@
1
1
  DLMS_SPODES_client/FCS16.py,sha256=RhoN4fX7eesKWfWCkRT_uWNfiQHqFd3T6lRwxfamUqw,2697
2
2
  DLMS_SPODES_client/__init__.py,sha256=6wphXvqkodng7h4nKNmkfldbaxf--IDVGfT0yNbas-o,449
3
- DLMS_SPODES_client/client.py,sha256=O6Z6lHcPzQ8YCxXYhw1Jo_m9Lz2EkoQ48InvDpBlEp8,110442
3
+ DLMS_SPODES_client/client.py,sha256=SHAJzsfoJBACcFnqFRPEdaRosgHEjRrKRvXkB0Nnsyo,110450
4
4
  DLMS_SPODES_client/logger.py,sha256=zAbihLloMU99w8Sw3djQ0cwItzyGq0Fz8DI9_suazv4,1913
5
5
  DLMS_SPODES_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  DLMS_SPODES_client/services.py,sha256=xM_-h322V1bGBcw9cJh7XOSUMTL3_E-GX89-z3YwIYw,3909
7
7
  DLMS_SPODES_client/session.py,sha256=1sa4wJny2xwDqL3DXpfYTS7mZcabVdC5fW1H60VB5QA,12681
8
8
  DLMS_SPODES_client/settings.py,sha256=6mitGe9UYeEgL61sf933MJ-S5N-ReoxvXqiI3agBGYE,1623
9
- DLMS_SPODES_client/task.py,sha256=OuVX4Q8BIKbUE3RCyf7qru9TfNDIOjBrL3ooXK-uDxI,73301
9
+ DLMS_SPODES_client/task.py,sha256=UoO30-funB7GdtkMV1O92w4J19RvdUTHBFLtvdnZJbc,73530
10
10
  DLMS_SPODES_client/gurux_common/enums/TraceLevel.py,sha256=Ne0Rn3c9ACqQjmde_ksbiQxIUv6nXsPQRnhkGwIv3QI,521
11
11
  DLMS_SPODES_client/gurux_common/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  DLMS_SPODES_client/gurux_dlms/AesGcmParameter.py,sha256=HJt0uvxtkqKEkvfiqXTMNsiayN15AgPJa9_iMSSFZsQ,1429
@@ -54,8 +54,8 @@ DLMS_SPODES_client/gurux_dlms/enums/Task.py,sha256=chuOL6-IMxBvABUZtoFcaYaQQB4GZ
54
54
  DLMS_SPODES_client/gurux_dlms/enums/VdeStateError.py,sha256=qT87LMbIYEs3TYPIp3N-dR2Tcg9KhKyiELwhVl5U-tw,233
55
55
  DLMS_SPODES_client/gurux_dlms/enums/__init__.py,sha256=F_sgGwNmmdpbKvP1klJQUNiLXxU2BtZ-LgEI9e6xP8g,1314
56
56
  DLMS_SPODES_client/gurux_dlms/internal/_GXCommon.py,sha256=7D9EYcfiZxwbk8sfpHv7s2nYqrbmGf-Tbwv2T-gqmgk,53226
57
- dlms_spodes_client-0.19.5.dist-info/METADATA,sha256=H3mlYrQaOvG2AL9fkK_irjJy0X0ifgONBSYePi4XUF4,985
58
- dlms_spodes_client-0.19.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
59
- dlms_spodes_client-0.19.5.dist-info/entry_points.txt,sha256=Z6UTeQjjCf2k1Y3Bjs0s7yr-UYSWb-TvJMuG2K2MApw,70
60
- dlms_spodes_client-0.19.5.dist-info/top_level.txt,sha256=rh_3Uig5bc6J_lKni01btol7dX_IgIJulNtGjGehmBE,19
61
- dlms_spodes_client-0.19.5.dist-info/RECORD,,
57
+ dlms_spodes_client-0.19.6.dist-info/METADATA,sha256=nnzRSETexkBVYyytykmBtUPx7O-AWSSFgjhkMiClWVM,985
58
+ dlms_spodes_client-0.19.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
59
+ dlms_spodes_client-0.19.6.dist-info/entry_points.txt,sha256=Z6UTeQjjCf2k1Y3Bjs0s7yr-UYSWb-TvJMuG2K2MApw,70
60
+ dlms_spodes_client-0.19.6.dist-info/top_level.txt,sha256=rh_3Uig5bc6J_lKni01btol7dX_IgIJulNtGjGehmBE,19
61
+ dlms_spodes_client-0.19.6.dist-info/RECORD,,