Skip to content

Commit

Permalink
Merge branch 'master' into v2.0.1-AttributeType-Enum-Corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared-Newell-Mobility committed Feb 7, 2024
2 parents 54fbb71 + 324abdd commit 02f941f
Show file tree
Hide file tree
Showing 14 changed files with 2,946 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @OrangeTux @tropxy
* @OrangeTux @tropxy @Jared-Newell-Mobility
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.version }}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Change log
- [#557](https://github.com/mobilityhouse/ocpp/issues/557) OCPP 2.0.1 Wrong data type in CostUpdated total_cost
- [#564](https://github.com/mobilityhouse/ocpp/issues/564) Add support For Python 3.11 and 3.12
- [#583](https://github.com/mobilityhouse/ocpp/issues/583) OCPP v1.6/v2.0.1 deprecate dataclasses from calls and call results with the suffix 'Payload'
- [#591](https://github.com/mobilityhouse/ocpp/issues/591) Camel_to_snake_case doesn't handle v2x correctly
- [#593](https://github.com/mobilityhouse/ocpp/issues/593) Update tests to use Call and CallResult without the suffix Payload

- [#577](https://github.com/mobilityhouse/ocpp/issues/577) v2.0.1 AttributeType Enum Corrections

Expand Down
8 changes: 7 additions & 1 deletion ocpp/charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def camel_to_snake_case(data):
if isinstance(data, dict):
snake_case_dict = {}
for key, value in data.items():
key = key.replace("V2X", "_v2x")
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", key)
key = re.sub("([a-z0-9])([A-Z])(?=\\S)", r"\1_\2", s1).lower()

Expand Down Expand Up @@ -311,9 +312,14 @@ async def call(self, payload, suppress=True, unique_id=None):
unique_id if unique_id is not None else str(self._unique_id_generator())
)

action_name = payload.__class__.__name__
# Due to deprecated call and callresults, remove in the future.
if "Payload" in payload.__class__.__name__:
action_name = payload.__class__.__name__[:-7]

call = Call(
unique_id=unique_id,
action=payload.__class__.__name__[:-7],
action=action_name,
payload=remove_nones(camel_case_payload),
)

Expand Down
4 changes: 2 additions & 2 deletions ocpp/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def __eq__(self, other):

def __repr__(self):
return (
f"<{self.__class__.__name__} - description={self.description},"
f"<{self.__class__.__name__} - description={self.description}, "
f" details={self.details}>"
)

def __str__(self):
return f"{self.__class__.__name__}: {self.description}," f" {self.details}"
return f"{self.__class__.__name__}: {self.description}, " f" {self.details}"


class NotImplementedError(OCPPError):
Expand Down
Loading

0 comments on commit 02f941f

Please sign in to comment.