Add boilerplate

This commit is contained in:
Marko Durkovic 2021-05-02 14:43:01 +02:00
commit 3628834c21
14 changed files with 672 additions and 0 deletions

21
.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
*.py[co]
*.egg-info/
.eggs/
__pycache__/
/build/
/dist/
/public/
/venv/
/.mypy_cache/
/.pytest_cache/
/htmlcov/
/.coverage
/coverage.xml
/report.xml
/tools/messages/[^.]*
*.sw[op]
/.vscode

46
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,46 @@
stages:
- test
- build
test:
stage: test
image: python:3.8
script:
- python3.8 -m venv venv
- venv/bin/python -m pip install -r requirements-dev.txt
- venv/bin/python -m pip install -e .[dev]
- venv/bin/python -m pytest
- venv/bin/python -m coverage xml
- venv/bin/sphinx-build docs public
coverage: '/\d+\%\s*$/'
artifacts:
paths:
- public
reports:
cobertura: coverage.xml
junit: report.xml
build:
stage: build
image: python:3.8
script:
- python3.8 -m venv venv
- venv/bin/python -m pip install build
- venv/bin/python -m build .
artifacts:
paths:
- dist
pages:
stage: build
image: python:3.8
script:
- ls public
artifacts:
paths:
- public
only:
- master

5
CHANGES.rst Normal file
View File

@ -0,0 +1,5 @@
.. _changes:
Changes
=======

78
CONTRIBUTING.rst Normal file
View File

@ -0,0 +1,78 @@
==================
Contribution guide
==================
Thank you for considering to contribute to rosbags. Below is information on how to report issues and submit your contributions to rosbags.
Rights to and license of contributions
======================================
Rosbags is licensed under `Apache 2.0`_. Your submission of an issue, merge request, comment, or code to us is:
1. If your employer has rights in your contributions, your representation that your employer has authorized you to enter into this agreement on its behalf;
2. Your agreement, or your employer's agreement, with the terms and conditions in this document;
3. Your signature of the `Developer Certificate of Origin`_; and
4. Your grant of a license to your contributions under `Apache 2.0`_.
Contributing code / merge requests
==================================
In order to contribute code there are a few noteworthy things:
1. Especially for non-trivial contributions, please **submit an issue first** to discuss your ideas.
2. If your merge requests relates to an existing issue, please reference it from your merge request.
3. When creating a merge request, please `allow collaboration`_. This enables us to make small adjustments and rebase the branch as needed. Please use dedicated branches for your merge request and don't give us access to a branch that is dear to you.
4. Stick to *The seven rules of a great Git commit message* (see below).
5. We require you to **sign-off your commits** (see below). Your sign-off indicates that you agreed to the terms and conditions laid out in this document, if applicable on behalf of your employer.
.. _allow collaboration:
https://docs.gitlab.com/ee/user/project/merge_requests/allow_collaboration.html
The seven rules of a great Git commit message
---------------------------------------------
We like `The seven rules of a great Git commit message`_, summarized here for completeness, follow links for further reading.
1. `Separate subject from body with a blank line <https://chris.beams.io/posts/git-commit/#separate>`_
2. `Limit the subject line to 50 characters <https://chris.beams.io/posts/git-commit/#limit-50>`_ (soft-limit 50, hard-limit 72)
3. `Start subject line with uppercase letter <https://chris.beams.io/posts/git-commit/#capitalize>`_
4. `Do not end the subject line with a period <https://chris.beams.io/posts/git-commit/#end>`_
5. `Use the imperative mood in the subject line <https://chris.beams.io/posts/git-commit/#imperative>`_
6. `Wrap the body at 72 characters <https://chris.beams.io/posts/git-commit/#wrap-72>`_
7. `Use the body to explain what and why vs. how <https://chris.beams.io/posts/git-commit/#why-not-how>`_
.. _The seven rules of a great Git commit message: https://chris.beams.io/posts/git-commit/#seven-rules
Signing off a commit
--------------------
You sign off a commit by adding a line like the following to the bottom of its commit message, separated by an empty line.
::
Signed-off-by: Fullname <email@example.net>
Make sure it reflects your real name and email address. Git does this automatically when using ``git commit -s``.
Except for the licenses granted herein, you reserve all right, title, and interest in and to your contributions.
.. _Apache 2.0: ./LICENSE.txt
.. _Developer Certificate of Origin: https://developercertificate.org/

202
LICENSE.txt Normal file
View File

@ -0,0 +1,202 @@
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.

85
README.rst Normal file
View File

@ -0,0 +1,85 @@
.. image:: https://gitlab.com/ternaris/rosbags/badges/master/pipeline.svg
:target: https://gitlab.com/ternaris/rosbags/-/commits/master
:alt: pipeline status
.. image:: https://gitlab.com/ternaris/rosbags/badges/master/coverage.svg
:target: https://gitlab.com/ternaris/rosbags/-/commits/master
:alt: coverage report
=======
Rosbags
=======
Rosbags is the **pure python** library for everything rosbag. It contains:
- **rosbag2** reader and writer,
- **rosbag1** reader for raw messages,
- **extensible** type system with serializers and deserializers,
- **efficient converter** between rosbag1 and rosbag2,
- and more.
Rosbags does not have any dependencies on the ROS software stacks and can be used on its own or alongside ROS1 or ROS2.
Rosbags was developed for `MARV <https://gitlab.com/ternaris/marv-robotics>`_, which requires a fast, correct, and flexible library to read, manipulate, and write the various rosbag file formats.
Getting started
===============
Rosbags is published on PyPI and does not have any special dependencies. Simply install with pip::
pip install rosbags
Documentation
=============
Read the `documentation <https://ternaris.gitlab.io/rosbags/>`_ for further information.
.. end documentation
Contributing
============
Thank you for considering to contribute to rosbags.
To submit issues or create merge requests please follow the instructions provided in the `contribution guide <https://gitlab.com/ternaris/rosbags/-/blob/master/CONTRIBUTING.rst>`_.
By contributing to rosbags you accept and agree to the terms and conditions laid out in there.
Development
===========
Clone the repository and setup your local checkout::
git clone https://gitlab.com/ternaris/rosbags.git
cd rosbags
python -m venv venv
. venv/bin/activate
pip install -r requirements-dev.txt
pip install -e .
This creates a new virtual environment with the necessary python dependencies and installs rosbags in editable mode. The rosbags code base uses pytest as its test runner, run the test suite by simply invoking::
pytest
To build the documentation from its source run sphinx-build::
sphinx-build -a docs public
The entry point to the local documentation build should be available under ``public/index.html``.
Support
=======
Professional support is available from `Ternaris <https://ternaris.com>`_.

6
docs/api/rosbags.rst Normal file
View File

@ -0,0 +1,6 @@
Rosbags namespace
=================
.. toctree::
:maxdepth: 4

1
docs/changes.rst Normal file
View File

@ -0,0 +1 @@
.. include:: ../CHANGES.rst

26
docs/conf.py Normal file
View File

@ -0,0 +1,26 @@
# Copyright 2020-2021 Ternaris.
# SPDX-License-Identifier: Apache-2.0
"""Sphinx config."""
import typing
import sphinx_rtd_theme # noqa pylint: disable=unused-import
# pylint: disable=invalid-name,redefined-builtin
typing.TYPE_CHECKING = True
project = 'Rosbags'
copyright = '2020-2021, Ternaris'
author = 'Ternaris'
autoapi_python_use_implicit_namespaces = True
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx_autodoc_typehints',
'sphinx_rtd_theme',
]
html_theme = 'sphinx_rtd_theme'

35
docs/index.rst Normal file
View File

@ -0,0 +1,35 @@
.. include:: ../README.rst
:end-before: Documentation
.. include:: ../README.rst
:start-after: .. end documentation
.. toctree::
:caption: Documentation
:maxdepth: 1
:hidden:
.. toctree::
:caption: API
:glob:
:hidden:
api/rosbags
.. toctree::
:caption: Changes
:hidden:
changes
.. toctree::
:caption: Links
:hidden:
Source Code <https://gitlab.com/ternaris/rosbags>
Issues <https://gitlab.com/ternaris/rosbags/issues>

3
pyproject.toml Normal file
View File

@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=56.2.0", "wheel"]
build-backend = "setuptools.build_meta"

157
setup.cfg Normal file
View File

@ -0,0 +1,157 @@
[metadata]
name = rosbags
version = 0.9.0
author = Ternaris
author_email = team@ternaris.com
home_page = https://gitlab.com/ternaris/rosbags
description = Pure Python library to read, modify, convert, and write rosbag files.
long_description = file: README.rst
long_description_content_type = text/x-rst
keywords =
cdr
conversion
deserialization
idl
message
msg
reader
ros
rosbag
rosbag2
serialization
writer
license = Apache 2.0
license_files = LICENSE.txt
platform = any
classifiers =
Development Status :: 4 - Beta
License :: OSI Approved :: Apache Software License
Programming Language :: Python
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Scientific/Engineering
Typing :: Typed
project_urls =
Code = https://gitlab.com/ternaris/rosbags
Documentation = https://ternaris.gitlab.io/rosbags
Issue tracker = https://gitlab.com/ternaris/rosbags/issues
[options]
include_package_data = true
package_dir =
= src
packages = find_namespace:
zip_safe = false
python_requires =
>=3.8.2
setup_requires =
setuptools >=40.8.0
wheel
install_requires =
lz4
numpy
ruamel.yaml
zstandard
[options.extras_require]
dev =
darglint
flake8
flake8-annotations
flake8-bugbear
flake8-commas
flake8-comprehensions
flake8-docstrings
flake8-fixme
flake8-isort
flake8-mutable
flake8-print
flake8-pytest-style
flake8-quotes
flake8-return
flake8-simplify
flake8-type-checking
flake8-use-fstring
pep8-naming
pytest
pytest-cov
pytest-flake8
pytest-mypy
pytest-pylint
sphinx
sphinx-autodoc-typehints
sphinx-rtd-theme
[options.packages.find]
where = src
[sdist]
formats = gztar, zip
[coverage:report]
exclude_lines =
pragma: no cover
if TYPE_CHECKING:
if __name__ == '__main__':
[flake8]
avoid-escape = False
docstring_convention = google
docstring_style = google
extend-select =
# docstrings
D204,
D400,
D401,
D404,
D413,
ignore =
# do not require annotation of `self`
ANN101,
# allow line break before binary operator
W503,
max-line-length = 100
strictness = long
suppress-none-returning = True
[isort]
include_trailing_comma = True
line_length = 100
multi_line_output = 3
[mypy]
ignore_missing_imports = True
[pydocstyle]
convention = google
add-select = D204,D400,D401,D404,D413
[pylint.FORMAT]
max-line-length = 100
[pylint.'MESSAGES CONTROL']
disable =
duplicate-code,
ungrouped-imports,
[yapf]
based_on_style = google
column_limit = 100
allow_split_before_dict_value = false
dedent_closing_brackets = true
indent_dictionary_value = false
[tool:pytest]
addopts =
-v
--flake8
--mypy
--pylint
--cov=src
--cov-branch
--cov-report=html
--cov-report=term
--no-cov-on-fail
--junitxml=report.xml
junit_family=xunit2

7
setup.py Normal file
View File

@ -0,0 +1,7 @@
# Copyright 2020-2021 Ternaris.
# SPDX-License-Identifier: Apache-2.0
"""Minimal setuptools boilerplate."""
from setuptools import setup # type: ignore
setup()

0
tools/messages/.gitkeep Normal file
View File