From 5c366a76080a094bc6b7786ce0cf852a3266b4b0 Mon Sep 17 00:00:00 2001 From: ipa-fez <28302109+ipa-fez@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:00:49 +0200 Subject: [PATCH 1/6] chore: dashed setup.cfg variables are deprecated --- vda5050_serializer/setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vda5050_serializer/setup.cfg b/vda5050_serializer/setup.cfg index 4f711a4..b3e1f31 100644 --- a/vda5050_serializer/setup.cfg +++ b/vda5050_serializer/setup.cfg @@ -1,4 +1,4 @@ [develop] -script-dir=$base/lib/vda5050_serializer +script_dir=$base/lib/vda5050_serializer [install] -install-scripts=$base/lib/vda5050_serializer +install_scripts=$base/lib/vda5050_serializer From 106c9b0eb536dd9cb77f1c2761cea62248bde4c7 Mon Sep 17 00:00:00 2001 From: Max Beutelspacher Date: Mon, 16 Sep 2024 12:41:16 +0200 Subject: [PATCH 2/6] feat(vda5050_serializer): turn action parameter values into json encoded string --- .../vda5050_serializer/__init__.py | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/vda5050_serializer/vda5050_serializer/__init__.py b/vda5050_serializer/vda5050_serializer/__init__.py index ac28ac6..c3c0117 100644 --- a/vda5050_serializer/vda5050_serializer/__init__.py +++ b/vda5050_serializer/vda5050_serializer/__init__.py @@ -18,8 +18,8 @@ def snakey(non_snake_string) -> str: - pattern = re.compile(r'(? str: @@ -28,7 +28,7 @@ def dromedary(non_dromedary_string) -> str: def camely(non_camel_string) -> str: - return ''.join(word[0].upper() + word[1:] for word in non_camel_string.split('_')) + return "".join(word[0].upper() + word[1:] for word in non_camel_string.split("_")) def transform_keys_in_dict(multilevel_dict, transformer): @@ -36,7 +36,6 @@ def transform_keys_in_dict(multilevel_dict, transformer): return multilevel_dict new_dict = {} for k, v in multilevel_dict.items(): - k = transformer(k) if isinstance(v, dict): @@ -49,6 +48,24 @@ def transform_keys_in_dict(multilevel_dict, transformer): return new_dict +def transform_action_parameter_values_to_json_string(multilevel_dict): + if not isinstance(multilevel_dict, dict): + return multilevel_dict + new_dict = {} + for k, v in multilevel_dict.items(): + if k == "action_parameters" and isinstance(v, list): + v = [{"key": elem["key"], "value": json.dumps(elem["value"])} for elem in v] + else: + if isinstance(v, dict): + v = transform_action_parameter_values_to_json_string(v) + if isinstance(v, list): + v = [transform_action_parameter_values_to_json_string(x) for x in v] + + assert k not in new_dict + new_dict[k] = v + return new_dict + + def dumps(d) -> str: return json.dumps(transform_keys_in_dict(d, dromedary)) @@ -57,3 +74,8 @@ def loads(str_val) -> dict: d = json.loads(str_val) return transform_keys_in_dict(d, snakey) + + +# retransforms all instances of action_parameters to turn the values into an json encoded string to support arbitrary types in the string message +def loads_transforming_action_parameter_values_to_json_string(str_val) -> dict: + return transform_action_parameter_values_to_json_string(loads(str_val)) From 24941849cc90c398923829de10b1bf13fe88d09f Mon Sep 17 00:00:00 2001 From: Philipp Schnattinger Date: Tue, 24 Sep 2024 14:12:37 +0200 Subject: [PATCH 3/6] fix: remove flake8 deps --- vda5050_serializer/package.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/vda5050_serializer/package.xml b/vda5050_serializer/package.xml index 4791070..c6a8b97 100644 --- a/vda5050_serializer/package.xml +++ b/vda5050_serializer/package.xml @@ -11,7 +11,6 @@ Apache2.0 ament_copyright - ament_flake8 ament_pep257 python3-pytest From bdf435faa58ebf4f626fc10ea7ff00429672a571 Mon Sep 17 00:00:00 2001 From: Philipp Schnattinger Date: Fri, 27 Sep 2024 09:17:59 +0200 Subject: [PATCH 4/6] chore: ament flake 8 compatibility --- .../vda5050_serializer/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/vda5050_serializer/vda5050_serializer/__init__.py b/vda5050_serializer/vda5050_serializer/__init__.py index c3c0117..2e9e9ee 100644 --- a/vda5050_serializer/vda5050_serializer/__init__.py +++ b/vda5050_serializer/vda5050_serializer/__init__.py @@ -1,14 +1,14 @@ #! /usr/bin/env python3 # Copyright 2020 Fraunhofer IPA # -# Licensed under the Apache License, Version 2.0 (the "License"); +# Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, +# distributed under the License is distributed on an 'AS IS' BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. @@ -18,8 +18,8 @@ def snakey(non_snake_string) -> str: - pattern = re.compile(r"(? str: @@ -28,7 +28,7 @@ def dromedary(non_dromedary_string) -> str: def camely(non_camel_string) -> str: - return "".join(word[0].upper() + word[1:] for word in non_camel_string.split("_")) + return ''.join(word[0].upper() + word[1:] for word in non_camel_string.split('_')) def transform_keys_in_dict(multilevel_dict, transformer): @@ -53,8 +53,8 @@ def transform_action_parameter_values_to_json_string(multilevel_dict): return multilevel_dict new_dict = {} for k, v in multilevel_dict.items(): - if k == "action_parameters" and isinstance(v, list): - v = [{"key": elem["key"], "value": json.dumps(elem["value"])} for elem in v] + if k == 'action_parameters' and isinstance(v, list): + v = [{'key': elem['key'], 'value': json.dumps(elem['value'])} for elem in v] else: if isinstance(v, dict): v = transform_action_parameter_values_to_json_string(v) @@ -76,6 +76,7 @@ def loads(str_val) -> dict: return transform_keys_in_dict(d, snakey) -# retransforms all instances of action_parameters to turn the values into an json encoded string to support arbitrary types in the string message +# retransforms all instances of action_parameters to turn the values into +# an json encoded string to support arbitrary types in the string message def loads_transforming_action_parameter_values_to_json_string(str_val) -> dict: return transform_action_parameter_values_to_json_string(loads(str_val)) From 9a987195a504966d49b9c4bea9744a5fc853d900 Mon Sep 17 00:00:00 2001 From: Ragesh Ramachandran <49311464+ipa-rar@users.noreply.github.com> Date: Wed, 16 Oct 2024 18:50:31 +0000 Subject: [PATCH 5/6] fic: remove ament_copyright test dependency --- vda5050_serializer/package.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/vda5050_serializer/package.xml b/vda5050_serializer/package.xml index c6a8b97..9dbe4f1 100644 --- a/vda5050_serializer/package.xml +++ b/vda5050_serializer/package.xml @@ -10,7 +10,6 @@ Jannik Abbenseth Apache2.0 - ament_copyright ament_pep257 python3-pytest From 045169a3d244d021bc3baf94215078e21b1bf39f Mon Sep 17 00:00:00 2001 From: Ragesh Ramachandran <49311464+ipa-rar@users.noreply.github.com> Date: Thu, 17 Oct 2024 08:02:48 +0000 Subject: [PATCH 6/6] fix: remove flake8 and copyright tests --- vda5050_serializer/test/test_copyright.py | 23 ----------------------- vda5050_serializer/test/test_flake8.py | 23 ----------------------- 2 files changed, 46 deletions(-) delete mode 100644 vda5050_serializer/test/test_copyright.py delete mode 100644 vda5050_serializer/test/test_flake8.py diff --git a/vda5050_serializer/test/test_copyright.py b/vda5050_serializer/test/test_copyright.py deleted file mode 100644 index cc8ff03..0000000 --- a/vda5050_serializer/test/test_copyright.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_copyright.main import main -import pytest - - -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/vda5050_serializer/test/test_flake8.py b/vda5050_serializer/test/test_flake8.py deleted file mode 100644 index eff8299..0000000 --- a/vda5050_serializer/test/test_flake8.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_flake8.main import main -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - rc = main(argv=[]) - assert rc == 0, 'Found errors'