From 3cc565d7db28f5c2dff552df263942620d24f763 Mon Sep 17 00:00:00 2001 From: Philipp Schnattinger Date: Thu, 10 Oct 2024 15:27:55 +0200 Subject: [PATCH] fix: add copyright --- CONTRIBUTING.md | 11 + LICENSE | 201 ++++++++++++++++++ vda5050_serializer/package.xml | 4 +- vda5050_serializer/setup.py | 30 ++- vda5050_serializer/test/test_copyright.py | 8 +- .../test/test_dict_converters.py | 53 +++-- vda5050_serializer/test/test_flake8.py | 23 -- vda5050_serializer/test/test_pep257.py | 8 +- .../test/test_string_converters.py | 34 +-- .../vda5050_serializer/__init__.py | 14 +- 10 files changed, 290 insertions(+), 96 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE delete mode 100644 vda5050_serializer/test/test_flake8.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..13e74f9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,11 @@ +# CONTRIBUTING + +## Contributing to vda5050_msgs + +Thank you for your interest in contributing! Here are the guidelines for contributing to this project. + +## Development Setup + +1. **Clone the repository:** + ```bash + git clone https://github.com/ipa320/vda5050_msgs.git diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vda5050_serializer/package.xml b/vda5050_serializer/package.xml index c6a8b97..fe40dfb 100644 --- a/vda5050_serializer/package.xml +++ b/vda5050_serializer/package.xml @@ -4,11 +4,11 @@ vda5050_serializer 0.0.0 - The serialization/deserialization functions to be loaded into the mqtt_bridge. During (de-)serialization + The serialization/deserialization functions to be loaded into the mqtt_bridge. During (de-)serialization the case of the keys is corrected from snake_case on ROS side to dromedaryCase on MQTT/JSON side Jannik Abbenseth - Apache2.0 + Apache 2.0 ament_copyright ament_pep257 diff --git a/vda5050_serializer/setup.py b/vda5050_serializer/setup.py index cf4fc9d..5e11d54 100644 --- a/vda5050_serializer/setup.py +++ b/vda5050_serializer/setup.py @@ -1,28 +1,26 @@ from setuptools import setup -package_name = 'vda5050_serializer' +package_name = "vda5050_serializer" setup( name=package_name, - version='0.0.0', + version="0.0.0", packages=[package_name], data_files=[ - ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), + ("share/ament_index/resource_index/packages", ["resource/" + package_name]), + ("share/" + package_name, ["package.xml"]), ], - install_requires=['setuptools', 'pytest'], + install_requires=["setuptools", "pytest"], zip_safe=True, - maintainer='Jannik Abbenseth', - maintainer_email='jannik.abbenseth@ipa.fraunhofer.de', - description='The serialization/deserialization functions to be loaded into ' + - 'the mqtt_bridge. During(de-)serialization the case of the keys is corrected' + - ' from snake_case on ROS side to dromedaryCase on MQTT/JSON side ', - license='Apache2.0', - tests_require=['pytest'], + maintainer="Jannik Abbenseth", + maintainer_email="jannik.abbenseth@ipa.fraunhofer.de", + description="The serialization/deserialization functions to be loaded into " + + "the mqtt_bridge. During(de-)serialization the case of the keys is corrected" + + " from snake_case on ROS side to dromedaryCase on MQTT/JSON side ", + license="Apache 2.0", + tests_require=["pytest"], entry_points={ - 'console_scripts': [ - ], + "console_scripts": [], }, - python_requires='>=3.5' + python_requires=">=3.5", ) diff --git a/vda5050_serializer/test/test_copyright.py b/vda5050_serializer/test/test_copyright.py index cc8ff03..3d39644 100644 --- a/vda5050_serializer/test/test_copyright.py +++ b/vda5050_serializer/test/test_copyright.py @@ -1,13 +1,13 @@ # Copyright 2015 Open Source Robotics Foundation, Inc. # -# 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. @@ -19,5 +19,5 @@ @pytest.mark.copyright @pytest.mark.linter def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' + rc = main(argv=[".", "test"]) + assert rc == 0, "Found errors" diff --git a/vda5050_serializer/test/test_dict_converters.py b/vda5050_serializer/test/test_dict_converters.py index ca69c43..63ddef6 100644 --- a/vda5050_serializer/test/test_dict_converters.py +++ b/vda5050_serializer/test/test_dict_converters.py @@ -1,13 +1,13 @@ # 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. @@ -16,46 +16,55 @@ def test_to_snake(): - dromedar_dict = {'map_id': 'test', 'actions': [ - {'actionId': 'cyber_id'}, {'actionId': 'cyberZ'}], 'cyBeRs': {'testZone': 1}} + dromedar_dict = { + "map_id": "test", + "actions": [{"actionId": "cyber_id"}, {"actionId": "cyberZ"}], + "cyBeRs": {"testZone": 1}, + } snake_dict = transform_keys_in_dict(dromedar_dict, snakey) print(snake_dict) - assert 'map_id' in snake_dict - assert 'mapId' not in snake_dict + assert "map_id" in snake_dict + assert "mapId" not in snake_dict - assert 'action_id' in snake_dict['actions'][0] - assert 'action_id' in snake_dict['actions'][1] + assert "action_id" in snake_dict["actions"][0] + assert "action_id" in snake_dict["actions"][1] - assert 'cy_be_rs' in snake_dict + assert "cy_be_rs" in snake_dict - assert 'test_zone' in snake_dict['cy_be_rs'] - assert snake_dict['actions'][1]['action_id'] == 'cyberZ' + assert "test_zone" in snake_dict["cy_be_rs"] + assert snake_dict["actions"][1]["action_id"] == "cyberZ" def test_to_snake_duplicate_key(): - dromedar_dict = {'mapId': 'test', 'actions': [ - {'actionId': 'cyber_id'}, {'actionId': 'cyberZ'}], 'map_id': {'testZone': 1}} + dromedar_dict = { + "mapId": "test", + "actions": [{"actionId": "cyber_id"}, {"actionId": "cyberZ"}], + "map_id": {"testZone": 1}, + } with pytest.raises(AssertionError): transform_keys_in_dict(dromedar_dict, snakey) def test_to_dromedary(): - snake_dict = {'map_id': 'test', 'actions': [ - {'action_id': 'cyber_id'}, {'action_id': 'cyberZ'}], 'cy_be_rs': {'testZone': 1}} + snake_dict = { + "map_id": "test", + "actions": [{"action_id": "cyber_id"}, {"action_id": "cyberZ"}], + "cy_be_rs": {"testZone": 1}, + } dromedar_dict = transform_keys_in_dict(snake_dict, dromedary) print(dromedar_dict) - assert 'mapId' in dromedar_dict - assert 'map_id' not in dromedar_dict + assert "mapId" in dromedar_dict + assert "map_id" not in dromedar_dict - assert 'actionId' in dromedar_dict['actions'][0] - assert 'actionId' in dromedar_dict['actions'][1] + assert "actionId" in dromedar_dict["actions"][0] + assert "actionId" in dromedar_dict["actions"][1] - assert 'cyBeRs' in dromedar_dict + assert "cyBeRs" in dromedar_dict - assert 'testZone' in dromedar_dict['cyBeRs'] - assert dromedar_dict['actions'][1]['actionId'] == 'cyberZ' + assert "testZone" in dromedar_dict["cyBeRs"] + assert dromedar_dict["actions"][1]["actionId"] == "cyberZ" 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' diff --git a/vda5050_serializer/test/test_pep257.py b/vda5050_serializer/test/test_pep257.py index b234a38..68ec4d7 100644 --- a/vda5050_serializer/test/test_pep257.py +++ b/vda5050_serializer/test/test_pep257.py @@ -1,13 +1,13 @@ # Copyright 2015 Open Source Robotics Foundation, Inc. # -# 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. @@ -19,5 +19,5 @@ @pytest.mark.linter @pytest.mark.pep257 def test_pep257(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' + rc = main(argv=[".", "test"]) + assert rc == 0, "Found code style errors / warnings" diff --git a/vda5050_serializer/test/test_string_converters.py b/vda5050_serializer/test/test_string_converters.py index b1fbf10..4165884 100644 --- a/vda5050_serializer/test/test_string_converters.py +++ b/vda5050_serializer/test/test_string_converters.py @@ -1,13 +1,13 @@ # 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. @@ -15,27 +15,27 @@ def test_snakey(): - assert snakey('dromedaryCase') != 'snake_case' - assert snakey('mapId') == 'map_id' - assert snakey('orderUpdateId') == 'order_update_id' - assert snakey('lastNodeSequenceId') == 'last_node_sequence_id' + assert snakey("dromedaryCase") != "snake_case" + assert snakey("mapId") == "map_id" + assert snakey("orderUpdateId") == "order_update_id" + assert snakey("lastNodeSequenceId") == "last_node_sequence_id" - assert snakey('last_node_sequence_id') == 'last_node_sequence_id' + assert snakey("last_node_sequence_id") == "last_node_sequence_id" def test_dromedary(): - assert dromedary('snake_case') != 'dromedaryCase' - assert dromedary('map_id') == 'mapId' - assert dromedary('order_update_id') == 'orderUpdateId' - assert dromedary('last_node_sequence_id') == 'lastNodeSequenceId' + assert dromedary("snake_case") != "dromedaryCase" + assert dromedary("map_id") == "mapId" + assert dromedary("order_update_id") == "orderUpdateId" + assert dromedary("last_node_sequence_id") == "lastNodeSequenceId" - assert dromedary('lastNodeSequenceId') == 'lastNodeSequenceId' + assert dromedary("lastNodeSequenceId") == "lastNodeSequenceId" def test_camely(): - assert camely('snake_case') != 'CamelCase' - assert camely('map_id') == 'MapId' - assert camely('order_update_id') == 'OrderUpdateId' - assert camely('last_node_sequence_id') == 'LastNodeSequenceId' + assert camely("snake_case") != "CamelCase" + assert camely("map_id") == "MapId" + assert camely("order_update_id") == "OrderUpdateId" + assert camely("last_node_sequence_id") == "LastNodeSequenceId" - assert camely('LastNodeSequenceId') == 'LastNodeSequenceId' + assert camely("LastNodeSequenceId") == "LastNodeSequenceId" diff --git a/vda5050_serializer/vda5050_serializer/__init__.py b/vda5050_serializer/vda5050_serializer/__init__.py index 2e9e9ee..25e48fd 100644 --- a/vda5050_serializer/vda5050_serializer/__init__.py +++ b/vda5050_serializer/vda5050_serializer/__init__.py @@ -4,9 +4,7 @@ # 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 -# +# 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. @@ -18,8 +16,8 @@ def snakey(non_snake_string) -> str: - pattern = re.compile(r'(? str: @@ -28,7 +26,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 +51,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)