tests: fix all basic type check issues of lttng_live_server.py master
authorSimon Marchi <simon.marchi@efficios.com>
Sat, 16 Sep 2023 01:44:44 +0000 (21:44 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 21 Sep 2023 17:29:44 +0000 (13:29 -0400)
Do the necessary changes such that this comment passes cleanly:

    $ PYTHONPATH=/home/smarchi/src/babeltrace/tests/utils/python pyright tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py

Pyright pointed out that field _trace_session_state didn't exist, in:

    @property
    def trace_session_state(self):
        return self._trace_session_state

The actual field name is _ts_state.  However, it shows that this
property is never used, so remove it.

Change-Id: I115fe473310ecdb1e2fd2e5d369aae33afe963f1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10893
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
567 files changed:
.editorconfig
.gitignore
CONTRIBUTING.adoc
LICENSE
LICENSES/PSF-2.0 [new file with mode: 0644]
README.adoc
configure.ac
dev-requirements.txt
doc/api/libbabeltrace2/examples/distill.c
doc/api/libbabeltrace2/examples/epitome.c
doc/bindings/python/ext/bt2sphinxurl.py
doc/bindings/python/source/conf.py
doc/man/babeltrace2-filter.lttng-utils.debug-info.7.txt
doc/man/babeltrace2-filter.utils.trimmer.7.txt
doc/man/babeltrace2-query.1.txt
doc/man/babeltrace2-sink.ctf.fs.7.txt
doc/man/babeltrace2-sink.text.details.7.txt
doc/man/babeltrace2-sink.text.pretty.7.txt
doc/man/babeltrace2-sink.utils.counter.7.txt
doc/man/babeltrace2-source.ctf.fs.7.txt
doc/man/babeltrace2-source.text.dmesg.7.txt
include/babeltrace2/graph/query-executor.h
include/babeltrace2/plugin/plugin-dev.h
m4/ax_pkg_swig.m4
pyproject.toml
setup.cfg
src/autodisc/autodisc.c
src/bindings/python/bt2/Makefile.am
src/bindings/python/bt2/bt2/__init__.py
src/bindings/python/bt2/bt2/clock_class.py
src/bindings/python/bt2/bt2/clock_snapshot.py
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/component_descriptor.py
src/bindings/python/bt2/bt2/connection.py
src/bindings/python/bt2/bt2/error.py
src/bindings/python/bt2/bt2/event.py
src/bindings/python/bt2/bt2/event_class.py
src/bindings/python/bt2/bt2/field.py
src/bindings/python/bt2/bt2/field_class.py
src/bindings/python/bt2/bt2/field_path.py
src/bindings/python/bt2/bt2/graph.py
src/bindings/python/bt2/bt2/integer_range_set.py
src/bindings/python/bt2/bt2/interrupter.py
src/bindings/python/bt2/bt2/message.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/mip.py
src/bindings/python/bt2/bt2/object.py
src/bindings/python/bt2/bt2/packet.py
src/bindings/python/bt2/bt2/plugin.py
src/bindings/python/bt2/bt2/port.py
src/bindings/python/bt2/bt2/py_plugin.py
src/bindings/python/bt2/bt2/query_executor.py
src/bindings/python/bt2/bt2/stream.py
src/bindings/python/bt2/bt2/stream_class.py
src/bindings/python/bt2/bt2/trace.py
src/bindings/python/bt2/bt2/trace_class.py
src/bindings/python/bt2/bt2/trace_collection_message_iterator.py
src/bindings/python/bt2/bt2/utils.py
src/bindings/python/bt2/bt2/value.py
src/bindings/python/bt2/setup.py.in
src/cli/Makefile.am
src/cli/babeltrace2-cfg-cli-args.c
src/cli/babeltrace2-plugins.h
src/cli/babeltrace2-query.c
src/cli/babeltrace2-query.h
src/cli/logging.c [deleted file]
src/cli/logging.cpp [new file with mode: 0644]
src/common/Makefile.am
src/common/align.h
src/common/assert.h
src/common/common.c
src/common/common.h
src/common/gen-version-i.sh [new file with mode: 0755]
src/common/macros.h
src/common/uuid.c
src/common/uuid.h
src/compat/mman.c
src/compat/mman.h
src/cpp-common/Makefile.am
src/cpp-common/align.hpp [new file with mode: 0644]
src/cpp-common/bt2/clock-class.hpp
src/cpp-common/bt2/clock-snapshot.hpp
src/cpp-common/bt2/common-iter.hpp [new file with mode: 0644]
src/cpp-common/bt2/exc.hpp [new file with mode: 0644]
src/cpp-common/bt2/field-class.hpp
src/cpp-common/bt2/field-path.hpp
src/cpp-common/bt2/field.hpp
src/cpp-common/bt2/integer-range-set.hpp
src/cpp-common/bt2/integer-range.hpp
src/cpp-common/bt2/internal/borrowed-obj.hpp
src/cpp-common/bt2/internal/shared-obj.hpp
src/cpp-common/bt2/internal/utils.hpp
src/cpp-common/bt2/lib-error.hpp [deleted file]
src/cpp-common/bt2/logging.hpp
src/cpp-common/bt2/message.hpp
src/cpp-common/bt2/trace-ir.hpp
src/cpp-common/bt2/type-traits.hpp [new file with mode: 0644]
src/cpp-common/bt2/value.hpp
src/cpp-common/cfg-error-reporting-throw.hpp [new file with mode: 0644]
src/cpp-common/cfg-error-reporting.hpp [new file with mode: 0644]
src/cpp-common/cfg-logging-error-reporting-throw.hpp [new file with mode: 0644]
src/cpp-common/cfg-logging-error-reporting.hpp [new file with mode: 0644]
src/cpp-common/cfg-logging.hpp [new file with mode: 0644]
src/cpp-common/endian.hpp [new file with mode: 0644]
src/cpp-common/exc.hpp [new file with mode: 0644]
src/cpp-common/glib-up.hpp [new file with mode: 0644]
src/cpp-common/lib-str.hpp [new file with mode: 0644]
src/cpp-common/libc-up.hpp [new file with mode: 0644]
src/cpp-common/log-cfg.hpp [new file with mode: 0644]
src/cpp-common/make-unique.hpp [new file with mode: 0644]
src/cpp-common/nlohmann/json.hpp [new file with mode: 0644]
src/cpp-common/read-fixed-len-int.hpp [new file with mode: 0644]
src/cpp-common/safe-ops.hpp [new file with mode: 0644]
src/cpp-common/std-int.hpp [new file with mode: 0644]
src/cpp-common/uuid-view.cpp [new file with mode: 0644]
src/cpp-common/uuid-view.hpp
src/cpp-common/uuid.hpp [new file with mode: 0644]
src/cpp-common/vector.hpp [new file with mode: 0644]
src/ctf-writer/attributes.c
src/ctf-writer/attributes.h
src/ctf-writer/clock-class.c
src/ctf-writer/clock-class.h
src/ctf-writer/clock.c
src/ctf-writer/clock.h
src/ctf-writer/event-class.c
src/ctf-writer/event-class.h
src/ctf-writer/event.c
src/ctf-writer/event.h
src/ctf-writer/field-path.c
src/ctf-writer/field-path.h
src/ctf-writer/field-types.c
src/ctf-writer/field-types.h
src/ctf-writer/field-wrapper.c
src/ctf-writer/field-wrapper.h
src/ctf-writer/fields.c
src/ctf-writer/fields.h
src/ctf-writer/functor.c
src/ctf-writer/functor.h
src/ctf-writer/object-pool.c
src/ctf-writer/object.c
src/ctf-writer/resolve.c
src/ctf-writer/resolve.h
src/ctf-writer/stream-class.c
src/ctf-writer/stream-class.h
src/ctf-writer/stream.c
src/ctf-writer/stream.h
src/ctf-writer/trace.c
src/ctf-writer/trace.h
src/ctf-writer/utils.c
src/ctf-writer/utils.h
src/ctf-writer/validation.c
src/ctf-writer/validation.h
src/ctf-writer/values.c
src/ctf-writer/values.h
src/ctf-writer/visitor.c
src/ctf-writer/visitor.h
src/ctf-writer/writer.c
src/ctf-writer/writer.h
src/ctfser/ctfser.c
src/ctfser/ctfser.h
src/fd-cache/fd-cache.c
src/fd-cache/fd-cache.h
src/lib/assert-cond-base.h
src/lib/assert-cond.c
src/lib/babeltrace2.c
src/lib/current-thread.c
src/lib/error.c
src/lib/error.h
src/lib/graph/component-class-sink-simple.c
src/lib/graph/component-class-sink-simple.h
src/lib/graph/component-class.c
src/lib/graph/component-class.h
src/lib/graph/component-descriptor-set.c
src/lib/graph/component-filter.c
src/lib/graph/component-filter.h
src/lib/graph/component-sink.c
src/lib/graph/component-sink.h
src/lib/graph/component-source.c
src/lib/graph/component-source.h
src/lib/graph/component.c
src/lib/graph/component.h
src/lib/graph/connection.c
src/lib/graph/connection.h
src/lib/graph/graph.c
src/lib/graph/graph.h
src/lib/graph/interrupter.c
src/lib/graph/iterator.c
src/lib/graph/message-iterator-class.c
src/lib/graph/message-iterator-class.h
src/lib/graph/message/discarded-items.c
src/lib/graph/message/event.c
src/lib/graph/message/event.h
src/lib/graph/message/iterator.h
src/lib/graph/message/message-iterator-inactivity.c
src/lib/graph/message/message.c
src/lib/graph/message/message.h
src/lib/graph/message/packet.c
src/lib/graph/message/packet.h
src/lib/graph/message/stream.c
src/lib/graph/mip.c
src/lib/graph/port.c
src/lib/graph/port.h
src/lib/graph/query-executor.c
src/lib/integer-range-set.c
src/lib/integer-range-set.h
src/lib/lib-logging.c
src/lib/logging.c
src/lib/logging.h
src/lib/object-pool.h
src/lib/plugin/plugin-so.c
src/lib/plugin/plugin-so.h
src/lib/plugin/plugin.c
src/lib/prio-heap/prio-heap.h
src/lib/trace-ir/attributes.c
src/lib/trace-ir/attributes.h
src/lib/trace-ir/clock-class.c
src/lib/trace-ir/clock-class.h
src/lib/trace-ir/clock-snapshot.c
src/lib/trace-ir/clock-snapshot.h
src/lib/trace-ir/event-class.c
src/lib/trace-ir/event-class.h
src/lib/trace-ir/event.c
src/lib/trace-ir/event.h
src/lib/trace-ir/field-class.c
src/lib/trace-ir/field-class.h
src/lib/trace-ir/field-path.c
src/lib/trace-ir/field-path.h
src/lib/trace-ir/field-wrapper.c
src/lib/trace-ir/field-wrapper.h
src/lib/trace-ir/field.c
src/lib/trace-ir/field.h
src/lib/trace-ir/packet.c
src/lib/trace-ir/packet.h
src/lib/trace-ir/resolve-field-path.c
src/lib/trace-ir/resolve-field-path.h
src/lib/trace-ir/stream-class.c
src/lib/trace-ir/stream-class.h
src/lib/trace-ir/stream.c
src/lib/trace-ir/stream.h
src/lib/trace-ir/trace-class.c
src/lib/trace-ir/trace-class.h
src/lib/trace-ir/trace.c
src/lib/trace-ir/trace.h
src/lib/util.c
src/lib/value.c
src/lib/value.h
src/logging/log.c
src/logging/log.h
src/param-parse/param-parse.c
src/param-parse/param-parse.h
src/plugins/common/muxing/muxing.c
src/plugins/common/muxing/muxing.h
src/plugins/common/param-validation/param-validation.h
src/plugins/ctf/common/bfcr/bfcr.cpp
src/plugins/ctf/common/bfcr/bfcr.hpp
src/plugins/ctf/common/metadata/ast.hpp
src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.cpp
src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.hpp
src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp
src/plugins/ctf/common/metadata/ctf-meta-translate.cpp
src/plugins/ctf/common/metadata/ctf-meta-update-alignments.cpp
src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.cpp
src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.cpp
src/plugins/ctf/common/metadata/ctf-meta-update-meanings.cpp
src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.cpp
src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.cpp
src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.cpp
src/plugins/ctf/common/metadata/ctf-meta-validate.cpp
src/plugins/ctf/common/metadata/ctf-meta-visitors.hpp
src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.cpp
src/plugins/ctf/common/metadata/ctf-meta.hpp
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.cpp
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.hpp
src/plugins/ctf/common/metadata/decoder.cpp
src/plugins/ctf/common/metadata/decoder.hpp
src/plugins/ctf/common/metadata/objstack.cpp
src/plugins/ctf/common/metadata/objstack.hpp
src/plugins/ctf/common/metadata/parser.ypp
src/plugins/ctf/common/metadata/scanner.hpp
src/plugins/ctf/common/metadata/visitor-generate-ir.cpp
src/plugins/ctf/common/msg-iter/msg-iter.cpp
src/plugins/ctf/common/msg-iter/msg-iter.hpp
src/plugins/ctf/fs-sink/fs-sink-stream.cpp
src/plugins/ctf/fs-sink/fs-sink-stream.hpp
src/plugins/ctf/fs-sink/fs-sink-trace.cpp
src/plugins/ctf/fs-sink/fs-sink-trace.hpp
src/plugins/ctf/fs-sink/fs-sink.cpp
src/plugins/ctf/fs-sink/fs-sink.hpp
src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.cpp
src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.hpp
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.hpp
src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/data-stream-file.hpp
src/plugins/ctf/fs-src/file.cpp
src/plugins/ctf/fs-src/file.hpp
src/plugins/ctf/fs-src/fs.cpp
src/plugins/ctf/fs-src/fs.hpp
src/plugins/ctf/fs-src/metadata.cpp
src/plugins/ctf/fs-src/metadata.hpp
src/plugins/ctf/fs-src/query.cpp
src/plugins/ctf/fs-src/query.hpp
src/plugins/ctf/lttng-live/data-stream.cpp
src/plugins/ctf/lttng-live/lttng-live.cpp
src/plugins/ctf/lttng-live/lttng-live.hpp
src/plugins/ctf/lttng-live/metadata.cpp
src/plugins/ctf/lttng-live/viewer-connection.cpp
src/plugins/lttng-utils/debug-info/bin-info.c
src/plugins/lttng-utils/debug-info/bin-info.h
src/plugins/lttng-utils/debug-info/crc32.h
src/plugins/lttng-utils/debug-info/debug-info.c
src/plugins/lttng-utils/debug-info/debug-info.h
src/plugins/lttng-utils/debug-info/dwarf.c
src/plugins/lttng-utils/debug-info/dwarf.h
src/plugins/lttng-utils/debug-info/trace-ir-data-copy.c
src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h
src/plugins/lttng-utils/debug-info/trace-ir-mapping.c
src/plugins/lttng-utils/debug-info/trace-ir-mapping.h
src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c
src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h
src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c
src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h
src/plugins/lttng-utils/debug-info/utils.c
src/plugins/lttng-utils/debug-info/utils.h
src/plugins/text/details/details.c
src/plugins/text/details/details.h
src/plugins/text/details/obj-lifetime-mgmt.c
src/plugins/text/details/obj-lifetime-mgmt.h
src/plugins/text/details/write.c
src/plugins/text/details/write.h
src/plugins/text/dmesg/dmesg.c
src/plugins/text/dmesg/dmesg.h
src/plugins/text/pretty/pretty.c
src/plugins/text/pretty/pretty.h
src/plugins/text/pretty/print.c
src/plugins/utils/counter/counter.c
src/plugins/utils/counter/counter.h
src/plugins/utils/dummy/dummy.c
src/plugins/utils/dummy/dummy.h
src/plugins/utils/muxer/muxer.c
src/plugins/utils/muxer/muxer.h
src/plugins/utils/trimmer/trimmer.c
src/plugins/utils/trimmer/trimmer.h
src/py-common/py-common.c
src/py-common/py-common.h
src/python-plugin-provider/python-plugin-provider.c
src/string-format/format-error.h
src/string-format/format-plugin-comp-cls-name.h
tests/Makefile.am
tests/bindings/python/bt2/test_clock_class.py
tests/bindings/python/bt2/test_component.py
tests/bindings/python/bt2/test_component_class.py
tests/bindings/python/bt2/test_component_descriptor.py
tests/bindings/python/bt2/test_connection.py
tests/bindings/python/bt2/test_error.py
tests/bindings/python/bt2/test_event.py
tests/bindings/python/bt2/test_event_class.py
tests/bindings/python/bt2/test_field.py
tests/bindings/python/bt2/test_field_class.py
tests/bindings/python/bt2/test_graph.py
tests/bindings/python/bt2/test_integer_range_set.py
tests/bindings/python/bt2/test_interrupter.py
tests/bindings/python/bt2/test_message.py
tests/bindings/python/bt2/test_message_iterator.py
tests/bindings/python/bt2/test_mip.py
tests/bindings/python/bt2/test_package.py
tests/bindings/python/bt2/test_packet.py
tests/bindings/python/bt2/test_plugin.py
tests/bindings/python/bt2/test_port.py
tests/bindings/python/bt2/test_python_bt2
tests/bindings/python/bt2/test_query_executor.py
tests/bindings/python/bt2/test_stream.py
tests/bindings/python/bt2/test_stream_class.py
tests/bindings/python/bt2/test_trace.py
tests/bindings/python/bt2/test_trace_class.py
tests/bindings/python/bt2/test_trace_collection_message_iterator.py
tests/bindings/python/bt2/test_value.py
tests/bindings/python/bt2/utils.py
tests/cli/convert/test_auto_source_discovery_grouping
tests/cli/convert/test_auto_source_discovery_log_level
tests/cli/convert/test_auto_source_discovery_params
tests/cli/convert/test_convert_args
tests/cli/list-plugins/test_list_plugins
tests/cli/params/test_params
tests/cli/query/test_query
tests/cli/test_exit_status
tests/cli/test_help
tests/cli/test_intersection
tests/cli/test_output_ctf_metadata
tests/cli/test_output_path_ctf_non_lttng_trace
tests/cli/test_packet_seq_num
tests/cli/test_trace_copy
tests/cli/test_trace_read
tests/cli/test_trimmer
tests/ctf-writer/test_ctf_writer
tests/data/auto-source-discovery/grouping/bt_plugin_test.py
tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py
tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py
tests/data/ctf-traces/fail/invalid-sequence-length-field-class/metadata [new file with mode: 0644]
tests/data/ctf-traces/fail/invalid-variant-selector-field-class/metadata [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/chan_0 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/chan_1 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/chan_2 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/chan_3 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/index/chan_0.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/index/chan_1.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/index/chan_2.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/index/chan_3.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10352-20190826-155748/metadata [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/chan_0 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/chan_1 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/chan_2 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/chan_3 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/index/chan_0.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/index/chan_1.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/index/chan_2.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/index/chan_3.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/20190826T155753-0400-3/ust/pid/hello-ust-10353-20190826-155748/metadata [deleted file]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/chan_0 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/chan_1 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/chan_2 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/chan_3 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/index/chan_0.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/index/chan_1.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/index/chan_2.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/index/chan_3.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10352/metadata [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/chan_0 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/chan_1 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/chan_2 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/chan_3 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/index/chan_0.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/index/chan_1.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/index/chan_2.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/index/chan_3.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/3/ust/pid/10353/metadata [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/chan_0 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/chan_1 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/chan_2 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/chan_3 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/index/chan_0.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/index/chan_1.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/index/chan_2.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/index/chan_3.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10352/metadata [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/chan_0 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/chan_1 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/chan_2 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/chan_3 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/index/chan_0.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/index/chan_1.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/index/chan_2.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/index/chan_3.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/1/ust/pid/10353/metadata [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/chan_0 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/chan_1 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/chan_2 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/chan_3 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/index/chan_0.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/index/chan_1.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/index/chan_2.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/index/chan_3.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10352/metadata [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/chan_0 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/chan_1 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/chan_2 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/chan_3 [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/index/chan_0.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/index/chan_1.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/index/chan_2.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/index/chan_3.idx [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/a/2/ust/pid/10353/metadata [new file with mode: 0644]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/chan_0 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/chan_1 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/chan_2 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/chan_3 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/index/chan_0.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/index/chan_1.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/index/chan_2.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/index/chan_3.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10352-20190826-155748/metadata [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/chan_0 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/chan_1 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/chan_2 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/chan_3 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/index/chan_0.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/index/chan_1.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/index/chan_2.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/index/chan_3.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155748-0400-20190826T155751-0400-1/ust/pid/hello-ust-10353-20190826-155748/metadata [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/chan_0 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/chan_1 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/chan_2 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/chan_3 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/index/chan_0.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/index/chan_1.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/index/chan_2.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/index/chan_3.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10352-20190826-155748/metadata [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/chan_0 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/chan_1 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/chan_2 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/chan_3 [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/index/chan_0.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/index/chan_1.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/index/chan_2.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/index/chan_3.idx [deleted file]
tests/data/ctf-traces/succeed/session-rotation/archives/20190826T155750-0400-20190826T155753-0400-2/ust/pid/hello-ust-10353-20190826-155748/metadata [deleted file]
tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py
tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py
tests/lib/Makefile.am
tests/lib/conds/Makefile.am
tests/lib/conds/conds-triggers.c [deleted file]
tests/lib/conds/conds-triggers.cpp [new file with mode: 0644]
tests/lib/conds/test.py
tests/lib/conds/test_conds
tests/lib/conds/utils.c [deleted file]
tests/lib/conds/utils.cpp [new file with mode: 0644]
tests/lib/conds/utils.h [deleted file]
tests/lib/conds/utils.hpp [new file with mode: 0644]
tests/lib/test_fields [new file with mode: 0755]
tests/lib/test_fields_bin.cpp [new file with mode: 0644]
tests/lib/test_graph_topo.c
tests/lib/test_plugin
tests/lib/utils/Makefile.am [new file with mode: 0644]
tests/lib/utils/run-in.cpp [new file with mode: 0644]
tests/lib/utils/run-in.hpp [new file with mode: 0644]
tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu
tests/plugins/flt.lttng-utils.debug-info/test_succeed
tests/plugins/flt.utils.muxer/succeed/test_succeed
tests/plugins/flt.utils.trimmer/test_trimming
tests/plugins/sink.ctf.fs/succeed/test_succeed
tests/plugins/sink.ctf.fs/test_assume_single_trace
tests/plugins/sink.ctf.fs/test_stream_names
tests/plugins/sink.text.details/succeed/test_succeed
tests/plugins/sink.text.pretty/test_enum
tests/plugins/sink.text.pretty/test_pretty.py
tests/plugins/sink.text.pretty/test_pretty_python
tests/plugins/src.ctf.fs/fail/test_fail
tests/plugins/src.ctf.fs/query/test_query_metadata_info
tests/plugins/src.ctf.fs/query/test_query_support_info
tests/plugins/src.ctf.fs/query/test_query_support_info.py
tests/plugins/src.ctf.fs/query/test_query_trace_info
tests/plugins/src.ctf.fs/query/test_query_trace_info.py
tests/plugins/src.ctf.fs/succeed/test_succeed
tests/plugins/src.ctf.fs/test_deterministic_ordering
tests/plugins/src.ctf.lttng-live/test_live
tests/python-plugin-provider/test_python_plugin_provider
tests/python-plugin-provider/test_python_plugin_provider.py
tests/utils/common.h
tests/utils/env.sh.in
tests/utils/python/cli_params_to_string.py
tests/utils/python/local_typing.py [new file with mode: 0644]
tests/utils/python/split_sort_compare.py
tests/utils/python/testrunner.py
tests/utils/python/utils.py [new file with mode: 0644]
tests/utils/run_python_bt2
tests/utils/tap/tap.h
tests/utils/utils.sh
tools/format-cpp

index 9461f5ba77c4432693913c11e8d82535a7b477e9..c01526f4f12e41e35a10e81d8ba74cb8763147ae 100644 (file)
@@ -12,3 +12,7 @@ tab_width = 8
 [*.{py,hpp,cpp}]
 indent_style = space
 indent_size = 4
+
+[*.{h,c}]
+indent_style = tab
+indent_size = 8
index 58610444071ce925d0ba68ad758c930c1532dce3..f61686207a30bdc1469fe11024d15e9f4aa38475 100644 (file)
@@ -4,6 +4,7 @@
 /tests/lib/plugin
 /tests/lib/test_bt_uuid
 /tests/lib/test_bt_values
+/tests/lib/test_fields_bin
 /tests/lib/test_graph_topo
 /tests/lib/test_trace_ir_ref
 /tests/lib/test_simple_sink
index 9af7a419c8f1968534ab28ccdb2111f716a7bb00..5435ff6efa1cb76474c9cd7c2113738a79512613 100644 (file)
@@ -439,7 +439,6 @@ level, for example:
 +
 [source,c]
 ----
-BT_HIDDEN
 char *bt_common_get_home_plugin_path(int log_level);
 ----
 +
@@ -1148,7 +1147,6 @@ struct my_comp {
     /* ... */
 };
 
-BT_HIDDEN
 bt_self_component_status my_comp_init(
         bt_self_component_source *self_comp_src,
         bt_value *params, void *init_method_data)
@@ -1676,7 +1674,7 @@ https://clang.llvm.org/docs/ClangFormatStyleOptions.html[style] of the
 You _must_ format modified and new {cpp} files with clang-format before
 you create a contribution patch.
 
-You need clang-format{nbsp}14 to use the project's `.clang-format` file.
+You need clang-format{nbsp}15 to use the project's `.clang-format` file.
 
 To automatically format all the project's {cpp} files, run:
 
@@ -1950,3 +1948,13 @@ private:
 #endif // BABELTRACE_BABY_HPP
 ----
 ====
+
+== Python Usage
+
+=== Formatting
+
+All Python code must be formatted using the version of
+https://github.com/psf/black[Black] specified in `dev-requirements.txt`.
+
+All Python imports must be sorted using the version of
+https://pycqa.github.io/isort/[isort] indicated in `dev-requirements.txt`.
diff --git a/LICENSE b/LICENSE
index 1beedf98e90d7984e3664f9dd44b399307f50b3c..e0e84e95f720d3104bb6fc077914f291eb38c665 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -92,6 +92,19 @@ This applies to:
 
        doc/api/libbabeltrace2/*
 
+The typing Python module is provided under the terms of the Python Software
+Foundation License 2:
+
+       SPDX-License-Identifier: PSF-2.0
+
+According with:
+
+       LICENSES/PSF-2.0
+
+This applies to:
+
+       tests/utils/python/local_typing.py
+
 
 In addition, other licenses may also apply, see SPDX-License-Identifier in
 individual files.
diff --git a/LICENSES/PSF-2.0 b/LICENSES/PSF-2.0
new file mode 100644 (file)
index 0000000..1df6b3b
--- /dev/null
@@ -0,0 +1,254 @@
+A. HISTORY OF THE SOFTWARE
+==========================
+
+Python was created in the early 1990s by Guido van Rossum at Stichting
+Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
+as a successor of a language called ABC.  Guido remains Python's
+principal author, although it includes many contributions from others.
+
+In 1995, Guido continued his work on Python at the Corporation for
+National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
+in Reston, Virginia where he released several versions of the
+software.
+
+In May 2000, Guido and the Python core development team moved to
+BeOpen.com to form the BeOpen PythonLabs team.  In October of the same
+year, the PythonLabs team moved to Digital Creations, which became
+Zope Corporation.  In 2001, the Python Software Foundation (PSF, see
+https://www.python.org/psf/) was formed, a non-profit organization
+created specifically to own Python-related Intellectual Property.
+Zope Corporation was a sponsoring member of the PSF.
+
+All Python releases are Open Source (see http://www.opensource.org for
+the Open Source Definition).  Historically, most, but not all, Python
+releases have also been GPL-compatible; the table below summarizes
+the various releases.
+
+    Release         Derived     Year        Owner       GPL-
+                    from                                compatible? (1)
+
+    0.9.0 thru 1.2              1991-1995   CWI         yes
+    1.3 thru 1.5.2  1.2         1995-1999   CNRI        yes
+    1.6             1.5.2       2000        CNRI        no
+    2.0             1.6         2000        BeOpen.com  no
+    1.6.1           1.6         2001        CNRI        yes (2)
+    2.1             2.0+1.6.1   2001        PSF         no
+    2.0.1           2.0+1.6.1   2001        PSF         yes
+    2.1.1           2.1+2.0.1   2001        PSF         yes
+    2.1.2           2.1.1       2002        PSF         yes
+    2.1.3           2.1.2       2002        PSF         yes
+    2.2 and above   2.1.1       2001-now    PSF         yes
+
+Footnotes:
+
+(1) GPL-compatible doesn't mean that we're distributing Python under
+    the GPL.  All Python licenses, unlike the GPL, let you distribute
+    a modified version without making your changes open source.  The
+    GPL-compatible licenses make it possible to combine Python with
+    other software that is released under the GPL; the others don't.
+
+(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
+    because its license has a choice of law clause.  According to
+    CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
+    is "not incompatible" with the GPL.
+
+Thanks to the many outside volunteers who have worked under Guido's
+direction to make these releases possible.
+
+
+B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
+===============================================================
+
+PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
+--------------------------------------------
+
+1. This LICENSE AGREEMENT is between the Python Software Foundation
+("PSF"), and the Individual or Organization ("Licensee") accessing and
+otherwise using this software ("Python") in source or binary form and
+its associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, PSF hereby
+grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
+analyze, test, perform and/or display publicly, prepare derivative works,
+distribute, and otherwise use Python alone or in any derivative version,
+provided, however, that PSF's License Agreement and PSF's notice of copyright,
+i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Python Software Foundation;
+All Rights Reserved" are retained in Python alone or in any derivative version
+prepared by Licensee.
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates Python or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to Python.
+
+4. PSF is making Python available to Licensee on an "AS IS"
+basis.  PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. Nothing in this License Agreement shall be deemed to create any
+relationship of agency, partnership, or joint venture between PSF and
+Licensee.  This License Agreement does not grant permission to use PSF
+trademarks or trade name in a trademark sense to endorse or promote
+products or services of Licensee, or any third party.
+
+8. By copying, installing or otherwise using Python, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
+
+
+BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
+-------------------------------------------
+
+BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
+
+1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
+office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
+Individual or Organization ("Licensee") accessing and otherwise using
+this software in source or binary form and its associated
+documentation ("the Software").
+
+2. Subject to the terms and conditions of this BeOpen Python License
+Agreement, BeOpen hereby grants Licensee a non-exclusive,
+royalty-free, world-wide license to reproduce, analyze, test, perform
+and/or display publicly, prepare derivative works, distribute, and
+otherwise use the Software alone or in any derivative version,
+provided, however, that the BeOpen Python License is retained in the
+Software, alone or in any derivative version prepared by Licensee.
+
+3. BeOpen is making the Software available to Licensee on an "AS IS"
+basis.  BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
+SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
+AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
+DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+5. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+6. This License Agreement shall be governed by and interpreted in all
+respects by the law of the State of California, excluding conflict of
+law provisions.  Nothing in this License Agreement shall be deemed to
+create any relationship of agency, partnership, or joint venture
+between BeOpen and Licensee.  This License Agreement does not grant
+permission to use BeOpen trademarks or trade names in a trademark
+sense to endorse or promote products or services of Licensee, or any
+third party.  As an exception, the "BeOpen Python" logos available at
+http://www.pythonlabs.com/logos.html may be used according to the
+permissions granted on that web page.
+
+7. By copying, installing or otherwise using the software, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
+
+
+CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
+---------------------------------------
+
+1. This LICENSE AGREEMENT is between the Corporation for National
+Research Initiatives, having an office at 1895 Preston White Drive,
+Reston, VA 20191 ("CNRI"), and the Individual or Organization
+("Licensee") accessing and otherwise using Python 1.6.1 software in
+source or binary form and its associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, CNRI
+hereby grants Licensee a nonexclusive, royalty-free, world-wide
+license to reproduce, analyze, test, perform and/or display publicly,
+prepare derivative works, distribute, and otherwise use Python 1.6.1
+alone or in any derivative version, provided, however, that CNRI's
+License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
+1995-2001 Corporation for National Research Initiatives; All Rights
+Reserved" are retained in Python 1.6.1 alone or in any derivative
+version prepared by Licensee.  Alternately, in lieu of CNRI's License
+Agreement, Licensee may substitute the following text (omitting the
+quotes): "Python 1.6.1 is made available subject to the terms and
+conditions in CNRI's License Agreement.  This Agreement together with
+Python 1.6.1 may be located on the internet using the following
+unique, persistent identifier (known as a handle): 1895.22/1013.  This
+Agreement may also be obtained from a proxy server on the internet
+using the following URL: http://hdl.handle.net/1895.22/1013".
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates Python 1.6.1 or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to Python 1.6.1.
+
+4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
+basis.  CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. This License Agreement shall be governed by the federal
+intellectual property law of the United States, including without
+limitation the federal copyright law, and, to the extent such
+U.S. federal law does not apply, by the law of the Commonwealth of
+Virginia, excluding Virginia's conflict of law provisions.
+Notwithstanding the foregoing, with regard to derivative works based
+on Python 1.6.1 that incorporate non-separable material that was
+previously distributed under the GNU General Public License (GPL), the
+law of the Commonwealth of Virginia shall govern this License
+Agreement only as to issues arising under or with respect to
+Paragraphs 4, 5, and 7 of this License Agreement.  Nothing in this
+License Agreement shall be deemed to create any relationship of
+agency, partnership, or joint venture between CNRI and Licensee.  This
+License Agreement does not grant permission to use CNRI trademarks or
+trade name in a trademark sense to endorse or promote products or
+services of Licensee, or any third party.
+
+8. By clicking on the "ACCEPT" button where indicated, or by copying,
+installing or otherwise using Python 1.6.1, Licensee agrees to be
+bound by the terms and conditions of this License Agreement.
+
+        ACCEPT
+
+
+CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
+--------------------------------------------------
+
+Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
+The Netherlands.  All rights reserved.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Stichting Mathematisch
+Centrum or CWI not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
index d43246ae43ddde43fc6d39a60024ec3bf6dff5e6..5d18414b9da6b4b37aa8d80e89b307903bbf19bb 100644 (file)
@@ -70,11 +70,11 @@ https://clang.llvm.org/[Clang] is one of those.
 Tools::
     * https://www.gnu.org/software/make/[GNU Make]
     * **If you build from a Git clone**:
-    ** https://www.gnu.org/software/automake/[GNU Automake]{nbsp}≥{nbsp}1.12
+    ** https://www.gnu.org/software/automake/[GNU Automake]{nbsp}≥{nbsp}1.13
     ** https://www.gnu.org/software/autoconf/[GNU Autoconf]{nbsp}≥{nbsp}2.69
     ** https://www.gnu.org/software/libtool/[GNU Libtool]{nbsp}≥{nbsp}2.2
     ** https://github.com/westes/flex[flex]{nbsp}≥{nbsp}2.5.35
-    ** https://www.gnu.org/software/bison/bison.html[GNU Bison]{nbsp}≥{nbsp}2.4
+    ** https://www.gnu.org/software/bison/bison.html[GNU Bison]{nbsp}≥{nbsp}2.5
 
 Libraries::
     * A C library (for example,
index 89884d973eb7b7bc85b4a0024bfe6b97a35db7ea..c7228ffe5a9137dd5ea22ddd436a97b34fb80862 100644 (file)
@@ -50,7 +50,7 @@ AC_CANONICAL_HOST
 ## Automake base setup ##
 ##                     ##
 
-AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip tar-ustar nostdinc -Wall -Wno-portability -Werror])
+AM_INIT_AUTOMAKE([1.13 foreign dist-bzip2 no-dist-gzip tar-ustar nostdinc -Wall -Wno-portability -Werror])
 AM_MAINTAINER_MODE([enable])
 
 # Enable silent rules by default
@@ -211,12 +211,12 @@ AX_PROG_BISON_VERSION([2.5], [have_bison=yes])
 AS_IF([test "x$have_bison" != "xyes"], [
   AE_IF_IN_GIT_REPO([
     AC_MSG_FAILURE([dnl
-Bison >= 2.4 is required when building from the Git repository. You can
+Bison >= 2.5 is required when building from the Git repository. You can
 set the YACC variable to override automatic detection.
     ])
   ], [
     AC_MSG_WARN([dnl
-Missing Bison >= 2.4. Note that the parser files are already built in
+Missing Bison >= 2.5. Note that the parser files are already built in
 this distribution tarball, so Bison is only needed if you intend to
 modify their sources. You can set the YACC variable to override automatic
 detection.
@@ -448,6 +448,7 @@ AE_FEATURE([Werror],[Treat compiler warnings as errors.])
 # When given, build with AddressSanitizer.
 AE_FEATURE_DEFAULT_DISABLE
 AE_FEATURE([asan],[Build with AddressSanitizer.])
+AE_FEATURE([ubsan],[Build with UndefinedBehaviorSanitizer.])
 
 ##                                          ##
 ## Check for conflicting features selection ##
@@ -538,6 +539,16 @@ AS_IF([AE_IS_FEATURE_ENABLED([python-bindings]) || AE_IS_FEATURE_ENABLED([python
   AS_IF([test "x$have_python_dev" = xno], [
     AC_MSG_ERROR([Cannot find a suitable python-config. You can override the python-config path with the PYTHON_CONFIG environment variable.])
   ])
+
+  AX_COMPARE_VERSION(["$PYTHON_VERSION"], [ge], ["3.12"], [
+    AC_MSG_CHECKING([for python setuptools])
+    AS_IF(["$PYTHON" -c "import setuptools" 2>/dev/null], [
+      AC_MSG_RESULT([yes])
+    ], [
+      AC_MSG_RESULT([no])
+      AC_MSG_ERROR([Python >= 3.12 removed 'distutils', the 'setuptools' module needs to be installed for the selected interpreter.])
+    ])
+  ])
 ])
 
 AE_IF_FEATURE_ENABLED([python-bindings-doc],
@@ -645,13 +656,19 @@ AE_IF_FEATURE_ENABLED([asan], [
   ASAN_LDFLAGS="-fsanitize=address"
 ])
 
-
+# If --enable-ubsan is used...
+AE_IF_FEATURE_ENABLED([ubsan], [
+  # ... add -fsanitize=undefined to the *FLAGS variables.
+  UBSAN_CFLAGS="-fsanitize=undefined"
+  UBSAN_CXXFLAGS="-fsanitize=undefined"
+  UBSAN_LDFLAGS="-fsanitize=undefined"
+])
 
 # CFLAGS from libraries (the glib ones are needed for the following sizeof
 # test).
-AM_CFLAGS="${PTHREAD_CFLAGS} ${GLIB_CFLAGS} ${ASAN_CFLAGS}"
-AM_CXXFLAGS="${PTHREAD_CFLAGS} ${GLIB_CFLAGS} ${ASAN_CXXFLAGS}"
-AM_LDFLAGS="${ASAN_LDFLAGS}"
+AM_CFLAGS="-fvisibility=hidden ${PTHREAD_CFLAGS} ${GLIB_CFLAGS} ${ASAN_CFLAGS} ${UBSAN_CFLAGS}"
+AM_CXXFLAGS="-fvisibility=hidden -fvisibility-inlines-hidden ${PTHREAD_CFLAGS} ${GLIB_CFLAGS} ${ASAN_CXXFLAGS} ${UBSAN_CFLAGS}"
+AM_LDFLAGS="${ASAN_LDFLAGS} ${UBSAN_CFLAGS}"
 
 # Check that the current size_t matches the size that glib thinks it should
 # be. This catches problems on multi-arch where people try to do a 32-bit
@@ -704,6 +721,7 @@ m4_define([WARN_FLAGS_LIST], [ dnl
   dnl Clang's does not.  Enable Clang's `-Wshadow-field-in-constructor`, to make
   dnl Clang warn about that.
   -Wshadow-field-in-constructor dnl
+  -Wshadow-field dnl
   -Wjump-misses-init dnl
   -Wsuggest-attribute=format dnl
   -Wtautological-constant-out-of-range-compare dnl
@@ -844,6 +862,7 @@ AC_CONFIG_FILES([
   tests/lib/Makefile
   tests/lib/test-plugin-plugins/Makefile
   tests/lib/conds/Makefile
+  tests/lib/utils/Makefile
   tests/Makefile
   tests/param-validation/Makefile
   tests/plugins/Makefile
index 452c0de654b52c01a7bad7582b1bd0125581fb7b..b68507adeed8fc83a667ed7f267a2682bfd4b2bc 100644 (file)
@@ -1,2 +1,5 @@
-black ~= 22.0
+black ~= 23.9.1
 flake8 >= 3.8
+# Required for black 22.0, it's broken with click >= 8.1
+click < 8.1
+isort ~= 5.12
index 81fe2e82776667a4ddb125c9d753507e94f5c63e..b52650f9e7a2ab043645f2a71bcdfe027fe6b040 100644 (file)
@@ -110,7 +110,7 @@ distill_message_iterator_initialize(
     /* Keep a link to the component's private data */
     distill_iter->distill = distill;
 
-    /* Create the uptream message iterator */
+    /* Create the upstream message iterator */
     bt_message_iterator_create_from_message_iterator(self_message_iterator,
         distill->in_port, &distill_iter->message_iterator);
 
index 852ca3f70775c13e39aeadbdc37c6c0e71627e16..ab68408ff39768772b8d5103303fd4277d6d94cc 100644 (file)
@@ -81,7 +81,7 @@ epitome_out_graph_is_configured(bt_self_component_sink *self_component_sink)
         bt_self_component_sink_borrow_input_port_by_index(
             self_component_sink, 0);
 
-    /* Create the uptream message iterator */
+    /* Create the upstream message iterator */
     bt_message_iterator_create_from_sink_component(self_component_sink,
         in_port, &epitome_out->message_iterator);
 
index d76cc1c777406f854f8f2bb3469c87db3ddcfaeb..830e0d1e2c4b3da88c61b5eddad38e31707ea564 100644 (file)
 #
 #         :bt2link:`libbabeltrace2 <https://babeltrace.org/docs/v@ver@/libbabeltrace2/>`
 
-import docutils
-import docutils.utils
-import docutils.nodes
 import re
 import functools
 
+import docutils
+import docutils.nodes
+import docutils.utils
+
 
 def _bt2man_role(
     bt2_version, name, rawtext, text, lineno, inliner, options=None, content=None
index 148cc92abca409abca0d4708ce03216b9f8e0d23..99e60af8942fe3535f00e9f924cf3c8c5e7bc288 100644 (file)
@@ -2,9 +2,10 @@
 #
 # Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
 
-import bt2
 import re
 
+import bt2
+
 # project
 project = "Babeltrace 2 Python bindings"
 copyright = "2020, EfficiOS, Inc"
index f98c7d7c29e599581cbe8626056485fd94aeebda..bccd85491c262e72b2b3bf6e63d7f35b52b1ca0c 100644 (file)
@@ -1,6 +1,6 @@
 = babeltrace2-filter.lttng-utils.debug-info(7)
 :manpagetype: component class
-:revdate: 14 September 2019
+:revdate: 1 September 2023
 :compcls: compcls:filter.lttng-utils.debug-info
 :defdebuginfoname: `debug_info`
 
@@ -229,10 +229,12 @@ param:debug-info-field-name='NAME' vtype:[optional string]::
     of the created events 'NAME' instead of the default
     {defdebuginfoname}.
 
-param:full-path=`yes` vtype:[optional boolean]::
-    Use the full path when writing the executable name (`bin`) and
-    source file name (`src`) fields in the {defdebuginfoname} context
-    field of the created events.
+param:full-path='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then use the full path when writing the executable
+    name (`bin`) and source file name (`src`) fields in the
+    {defdebuginfoname} context field of the created events.
++
+Default: false.
 
 param:target-prefix='DIR' vtype:[optional string]::
     Use 'DIR' as the root directory of the target file system instead of
index b1f754e5810c64eb3efcefbbcae4e919beaf2f83..707aac6c4a1dacd8df0060f1f9f5e8aacda4ef85 100644 (file)
@@ -1,6 +1,6 @@
 = babeltrace2-filter.utils.trimmer(7)
 :manpagetype: component class
-:revdate: 14 September 2019
+:revdate: 1 September 2023
 
 
 == NAME
@@ -74,9 +74,11 @@ treats it as such.
 If you don't specify this parameter, the component discards no events
 from the beginning of the trimming time range.
 
-param:gmt=`yes` vtype:[optional boolean]::
-    Set the time zone of the param:begin and param:end parameters
-    to GMT instead of the local time zone.
+param:gmt='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then set the time zone of the param:begin and
+    param:end parameters to GMT instead of the local time zone.
++
+Default: false.
 
 
 == PORTS
index c9e13456a0cb61aec4211e33f3ee8f56399040f3..22dd1f5f7892b765afd3ff7ed2b7098bc6530843 100644 (file)
@@ -85,7 +85,7 @@ $ babeltrace2 query src.ctf.lttng-live sessions \
 [role="term"]
 ----
 $ babeltrace2 query src.ctf.fs metadata-info \
-                    --params='path="/path/to/trace"'
+                    --params='inputs=["/path/to/trace"]'
 ----
 ====
 
@@ -94,7 +94,7 @@ $ babeltrace2 query src.ctf.fs metadata-info \
 [role="term"]
 ----
 $ babeltrace2 query src.ctf.fs babeltrace.trace-infos \
-                    --params='path="/path/to/trace"'
+                    --params='inputs=["/path/to/trace"]'
 ----
 ====
 
index df91341489b2aa484258d19b466a56e15eb02f2f..736602772465acc23c9d045e033a0d26f1448090 100644 (file)
@@ -1,6 +1,6 @@
 = babeltrace2-sink.ctf.fs(7)
 :manpagetype: component class
-:revdate: 14 September 2019
+:revdate: 1 September 2023
 
 
 == NAME
@@ -194,18 +194,24 @@ until the path does not exist.
 
 == INITIALIZATION PARAMETERS
 
-param:assume-single-trace=`yes` vtype:[optional boolean]::
-    Assume that the component only receives messages related to a single
-    input trace.
+param:assume-single-trace='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then assume that the component only receives
+    messages related to a single input trace.
 +
 This parameter affects how the component builds the output trace path
 (see <<output-path,``Output path''>>).
++
+Default: false.
 
-param:ignore-discarded-events=`yes` vtype:[optional boolean]::
-    Ignore discarded events messages.
+param:ignore-discarded-events='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then ignore discarded events messages.
++
+Default: false.
 
-param:ignore-discarded-packets=`yes` vtype:[optional boolean]::
-    Ignore discarded packets messages.
+param:ignore-discarded-packets='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then ignore discarded packets messages.
++
+Default: false.
 
 param:path='PATH' vtype:[string]::
     Base output path.
@@ -213,8 +219,10 @@ param:path='PATH' vtype:[string]::
 See <<output-path,``Output path''>> to learn how the component uses this
 parameter to build the output path for a given input trace.
 
-param:quiet=`yes` vtype:[optional boolean]::
-    Do not write anything to the standard output.
+param:quiet='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then do not write anything to the standard output.
++
+Default: false.
 
 
 == PORTS
index dc8792194ec4669c8bec0c9c4e976925e927dae8..8a23dd4e49fccd475d4c10312902b2f58d52dec7 100644 (file)
@@ -1,6 +1,6 @@
 = babeltrace2-sink.text.details(7)
 :manpagetype: component class
-:revdate: 14 September 2019
+:revdate: 1 September 2023
 
 
 == NAME
@@ -113,8 +113,8 @@ param:color=(`never` | `auto` | `always`) vtype:[optional string]::
 The `BABELTRACE_TERM_COLOR` environment variable overrides this
 parameter.
 
-param:compact=`yes` vtype:[optional boolean]::
-    Enable compact mode.
+param:compact='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then enable compact mode.
 +
 In compact mode, the component prints one line per message, omitting
 many details about messages. This is useful if you only need the time,
@@ -122,24 +122,38 @@ type, and very basic information of messages.
 +
 In compact mode, the component still prints the full metadata blocks.
 You can remove such blocks with the param:with-metadata parameter.
++
+Default: false.
 
-param:with-metadata=`no` vtype:[optional boolean]::
-    Do not print metadata blocks.
+param:with-metadata='VAL' vtype:[optional boolean]::
+    If 'VAL' is false, then do not print metadata blocks.
++
+Default: true.
 
-param:with-stream-class-name=`no` vtype:[optional boolean]::
-    Do not print stream class names.
+param:with-stream-class-name='VAL' vtype:[optional boolean]::
+    If 'VAL' is false, then do not print stream class names.
++
+Default: true.
 
-param:with-stream-name=`no` vtype:[optional boolean]::
-    Do not print stream names.
+param:with-stream-name='VAL' vtype:[optional boolean]::
+    If 'VAL' is false, then do not print stream names.
++
+Default: true.
 
-param:with-time=`no` vtype:[optional boolean]::
-    Do not print timing information.
+param:with-time='VAL' vtype:[optional boolean]::
+    If 'VAL' is false, then do not print timing information.
++
+Default: true.
 
-param:with-trace-name=`no` vtype:[optional boolean]::
-    Do not print trace names.
+param:with-trace-name='VAL' vtype:[optional boolean]::
+    If 'VAL' is false, then do not print trace names.
++
+Default: true.
 
-param:with-uuid=`no` vtype:[optional boolean]::
-    Do not print UUIDs.
+param:with-uuid='VAL' vtype:[optional boolean]::
+    If 'VAL' is false, then do not print UUIDs.
++
+Default: true.
 
 
 == PORTS
index 6d0cd292529542adc789e8f409ad5b88c8756c7f..496879117354bb80bda174c00996560be9321276 100644 (file)
@@ -1,6 +1,6 @@
 = babeltrace2-sink.text.pretty(7)
 :manpagetype: component class
-:revdate: 14 September 2019
+:revdate: 1 September 2023
 
 
 == NAME
@@ -43,20 +43,28 @@ man:babeltrace(1) (Babeltrace~1 command-line tool).
 
 == INITIALIZATION PARAMETERS
 
-param:clock-cycles=`yes` vtype:[optional boolean]::
-    Print event times in clock cycles instead of hours, minutes,
-    seconds, and nanoseconds.
+param:clock-cycles='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then print event times in clock cycles instead of
+    hours, minutes, seconds, and nanoseconds.
++
+Default: false.
 
-param:clock-date=`yes` vtype:[optional boolean]::
-    Print event times _and_ dates.
+param:clock-date='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then print event times _and_ dates.
++
+Default: false.
 
-param:clock-gmt=`yes` vtype:[optional boolean]::
-    Print event times in the GMT time zone instead of the local time
-    zone.
+param:clock-gmt='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then print event times in the GMT time zone
+    instead of the local time zone.
++
+Default: false.
 
-param:clock-seconds=`yes` vtype:[optional boolean]::
-    Print event times in seconds instead of hours, minutes,
-    seconds, and nanoseconds.
+param:clock-seconds='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then print event times in seconds instead of
+    hours, minutes, seconds, and nanoseconds.
++
+Default: false.
 
 param:color=(`never` | `auto` | `always`) vtype:[optional string]::
     Force the terminal color support, one of:
@@ -80,52 +88,200 @@ param:field-default=(`show` | `hide`) vtype:[optional string]::
     By default, show or hide all the fields. This sets the default value
     of all the parameters which start with `field-`.
 
-param:field-emf=(`yes` | `no`) vtype:[optional boolean]::
+param:field-emf='VAL' vtype:[optional boolean]::
     Show or hide the event's Eclipse Modeling Framework URI field.
++
+Default, depending on the param:field-default parameter:
++
+--
+`show`::
+    True
+
+`hide`::
+    False
+
+Not set::
+    False
+--
 
-param:field-loglevel=(`yes` | `no`) vtype:[optional boolean]::
+param:field-loglevel='VAL' vtype:[optional boolean]::
     Show or hide the event's logging level field.
++
+Default, depending on the param:field-default parameter:
++
+--
+`show`::
+    True
 
-param:field-trace=(`yes` | `no`) vtype:[optional boolean]::
+`hide`::
+    False
+
+Not set::
+    False
+--
+
+param:field-trace='VAL' vtype:[optional boolean]::
     Show or hide the trace name field.
++
+Default, depending on the param:field-default parameter:
++
+--
+`show`::
+    True
 
-param:field-trace:domain=(`yes` | `no`) vtype:[optional boolean]::
+`hide`::
+    False
+
+Not set::
+    False
+--
+
+param:field-trace:domain='VAL' vtype:[optional boolean]::
     Show or hide the tracing domain field.
++
+Default, depending on the param:field-default parameter:
++
+--
+`show`::
+    True
+
+`hide`::
+    False
+
+Not set::
+    False
+--
 
-param:field-trace:hostname=(`yes` | `no`) vtype:[optional boolean]::
+param:field-trace:hostname='VAL' vtype:[optional boolean]::
     Show or hide the hostname field.
++
+Default, depending on the param:field-default parameter:
++
+--
+`show`::
+    True
 
-param:field-trace:procname=(`yes` | `no`) vtype:[optional boolean]::
+`hide`::
+    False
+
+Not set::
+    True
+--
+
+param:field-trace:procname='VAL' vtype:[optional boolean]::
     Show or hide the process name field.
++
+Default, depending on the param:field-default parameter:
++
+--
+`show`::
+    True
 
-param:field-trace:vpid=(`yes` | `no`) vtype:[optional boolean]::
+`hide`::
+    False
+
+Not set::
+    True
+--
+
+param:field-trace:vpid='VAL' vtype:[optional boolean]::
     Show or hide the virtual process ID field.
++
+Default, depending on the param:field-default parameter:
++
+--
+`show`::
+    True
 
-param:name-context=(`yes` | `no`) vtype:[optional boolean]::
-    Show or hide the field names in the context scopes.
+`hide`::
+    False
+
+Not set::
+    True
+--
 
 param:name-default=(`show` | `hide`) vtype:[optional string]::
     By default, show or hide all the names. This sets the
     default value of all the parameters which start with `name-`.
 
-param:name-header=(`yes` | `no`) vtype:[optional boolean]::
+param:name-header='VAL' vtype:[optional boolean]::
     Show or hide the field names in the header scopes.
++
+Default, depending on the param:name-default parameter:
++
+--
+`show`::
+    True
+
+`hide`::
+    False
+
+Not set::
+    False
+--
 
-param:name-payload=(`yes` | `no`) vtype:[optional boolean]::
+param:name-context='VAL' vtype:[optional boolean]::
+    Show or hide the field names in the context scopes.
++
+Default, depending on the param:name-default parameter:
++
+--
+`show`::
+    True
+
+`hide`::
+    False
+
+Not set::
+    True
+--
+
+param:name-payload='VAL' vtype:[optional boolean]::
     Show or hide the field names in the event payload scopes.
++
+Default, depending on the param:name-default parameter:
++
+--
+`show`::
+    True
+
+`hide`::
+    False
+
+Not set::
+    True
+--
 
-param:name-scope=(`yes` | `no`) vtype:[optional boolean]::
+param:name-scope='VAL' vtype:[optional boolean]::
     Show or hide the scope names.
++
+Default, depending on the param:name-default parameter:
++
+--
+`show`::
+    True
 
-param:no-delta=`yes` vtype:[optional boolean]::
-    Do not print the time delta between consecutive lines.
+`hide`::
+    False
+
+Not set::
+    False
+--
+
+param:no-delta='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then do not print the time delta between
+    consecutive lines.
++
+Default: false.
 
 param:path='PATH' vtype:[optional string]::
     Print the text output to the file 'PATH' instead of the standard
     output.
 
-param:verbose=`yes` vtype:[optional boolean]::
-    Turn the verbose mode on.
+param:verbose='VAL' vtype:[optional boolean]::
+    If 'VAL' if true, then turn the verbose mode on.
++
+Default: false.
 
 
 == PORTS
index 60f051d50abf176e779854cd01d823a17e139888..082750a0c634ec8804eb92711358cd34494a76e5 100644 (file)
@@ -1,6 +1,6 @@
 = babeltrace2-sink.utils.counter(7)
 :manpagetype: component class
-:revdate: 14 September 2019
+:revdate: 1 September 2023
 
 
 == NAME
@@ -54,8 +54,11 @@ the zero counts with the param:hide-zero parameter.
 
 == INITIALIZATION PARAMETERS
 
-param:hide-zero=`yes` vtype:[optional boolean]::
-    Do not print the statistics lines where the count is zero.
+param:hide-zero='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then do not print the statistics lines where the
+    count is zero.
++
+Default: false.
 
 param:step='STEP' vtype:[optional unsigned integer]::
     Print a new block of statistics every 'STEP' consumed messages
index 3156ee542bccaa204427d301447b433496ba0d61..7aa20b696be10e030aeba5f7dae8a4241457cfbb 100644 (file)
@@ -1,6 +1,6 @@
 = babeltrace2-source.ctf.fs(7)
 :manpagetype: component class
-:revdate: 14 September 2019
+:revdate: 1 September 2023
 
 
 == NAME
@@ -167,9 +167,12 @@ param:clock-class-offset-s='SEC' vtype:[optional signed integer]::
 You can combine this parameter with the param:clock-class-offset-ns
 parameter.
 
-param:force-clock-class-origin-unix-epoch=`yes` vtype:[optional boolean]::
-    Force the origin of all clock classes that the component creates to
-    have a Unix epoch origin, whatever the detected tracer.
+param:force-clock-class-origin-unix-epoch='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then force the origin of all clock classes that
+    the component creates to have a Unix epoch origin, whatever the
+    detected tracer.
++
+Default: false.
 
 param:inputs='DIRS' vtype:[array of strings]::
     Open and read the physical CTF traces located in 'DIRS'.
index 9079fe4b4331890a85c016019187e4a3d84e5e5a..1e75c9d29870da0d5e7ecb04b1e83ca238a78736 100644 (file)
@@ -1,6 +1,6 @@
 = babeltrace2-source.text.dmesg(7)
 :manpagetype: component class
-:revdate: 14 September 2019
+:revdate: 1 September 2023
 
 
 == NAME
@@ -69,10 +69,12 @@ requires that the input kernel ring buffer lines be sorted by timestamp
 
 == INITIALIZATION PARAMETERS
 
-param:no-extract-timestamp=`yes` vtype:[optional boolean]::
-    Do :not: extract timestamps from the kernel ring buffer lines: set
-    the created event's payload's `str` field to the whole line,
-    including any timestamp prefix.
+param:no-extract-timestamp='VAL' vtype:[optional boolean]::
+    If 'VAL' is true, then do :not: extract timestamps from the kernel
+    ring buffer lines: set the created event's payload's `str` field to
+    the whole line, including any timestamp prefix.
++
+Default: false.
 
 param:path='PATH' vtype:[optional string]::
     Read the kernel ring buffer lines from the file 'PATH' instead of
index d4ef58f97ab2a6c6b2b6c7682f5afebd45bc328c..999aa0ab12a2bc562ff0e3da6691aa80fe44874e 100644 (file)
@@ -173,7 +173,7 @@ executor, the query method of \bt_p{component_class} receives:
     to create.
 
     Unlike the \bt_p{params} parameter of
-    the <code>bt_graph_add_*_component_*_port_added_listener()</code>
+    the <code>bt_graph_add_*_component*()</code>
     functions (see \ref api-graph), this parameter does not need to
     be a \bt_map_val.
 
index 1c8d0154097c849201cab9bb1108ce12d7538d17..f4444f92040f7d96fd7a5414cef6419ef01762dd 100644 (file)
 #define _BT_HIDDEN __attribute__((visibility("hidden")))
 #endif
 
+/*
+ * _BT_EXPORT: set the visibility for exported functions.
+ */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define _BT_EXPORT
+#else
+#define _BT_EXPORT __attribute__((visibility("default")))
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -336,35 +345,35 @@ other <code>BT_PLUGIN*()</code> macro.
        _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA; \
        _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA; \
        \
-       struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_END_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
        }
index 1d467de3d51f5f0b180a39c5627203a307797d5b..7a4196ff5dffdac5f47af65351efd5042c06a439 100644 (file)
@@ -36,6 +36,8 @@
 #   Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
 #   Copyright (c) 2008 Andrew Collier
 #   Copyright (c) 2011 Murray Cumming <murrayc@openismus.com>
+#   Copyright (c) 2018 Reini Urban <rurban@cpan.org>
+#   Copyright (c) 2021 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
 #
 #   This program is free software; you can redistribute it and/or modify it
 #   under the terms of the GNU General Public License as published by the
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
-#serial 13
+#serial 15
 
 AC_DEFUN([AX_PKG_SWIG],[
         # Find path to the "swig" executable.
         AC_PATH_PROGS([SWIG],[swig swig3.0 swig2.0])
         if test -z "$SWIG" ; then
                 m4_ifval([$3],[$3],[:])
-        elif test -n "$1" ; then
+        elif test -z "$1" ; then
+                m4_ifval([$2],[$2],[:])
+       else
                 AC_MSG_CHECKING([SWIG version])
                 [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
                 AC_MSG_RESULT([$swig_version])
@@ -81,12 +85,12 @@ AC_DEFUN([AX_PKG_SWIG],[
                         if test -z "$required_major" ; then
                                 [required_major=0]
                         fi
-                        [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
+                        [required=`echo $required. | sed 's/[0-9]*[^0-9]//'`]
                         [required_minor=`echo $required | sed 's/[^0-9].*//'`]
                         if test -z "$required_minor" ; then
                                 [required_minor=0]
                         fi
-                        [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
+                        [required=`echo $required. | sed 's/[0-9]*[^0-9]//'`]
                         [required_patch=`echo $required | sed 's/[^0-9].*//'`]
                         if test -z "$required_patch" ; then
                                 [required_patch=0]
@@ -121,7 +125,7 @@ AC_DEFUN([AX_PKG_SWIG],[
                                 m4_ifval([$3],[$3],[])
                         else
                                 AC_MSG_CHECKING([for SWIG library])
-                                SWIG_LIB=`$SWIG -swiglib`
+                                SWIG_LIB=`$SWIG -swiglib | tr '\r\n' '  '`
                                 AC_MSG_RESULT([$SWIG_LIB])
                                 m4_ifval([$2],[$2],[])
                         fi
index 39d5b4a34258a46003a3cea6e0b308d7ef7e1ae7..2dac3d6c887d8f84125789f94ac768cd987b410d 100644 (file)
      | src/bindings/python/bt2/setup\.py$
      | src/bindings/python/bt2/bt2/native_bt\.py$
      | src/bindings/python/bt2/bt2/version\.py$
+     | tests/utils/python/local_typing\.py$
      | tests/utils/python/tap
 
   )
   '''
+
+[tool.isort]
+profile = "black"
+extend_skip_glob = [
+    "tests/utils/python/tap",
+    "tests/utils/python/local_typing.py",
+]
+length_sort = true
index 9a58dd3cf6812ae271139dc0e78da87c4c627f1e..1d29ccadf04b0031d7954fff124a4c3e55b3b868 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -8,4 +8,4 @@ ignore = E501,W503
 # warning for this file.
 per-file-ignores = src/bindings/python/bt2/bt2/__init__.py:F401
 
-exclude = tests/utils/python/tap
+exclude = tests/utils/python/tap tests/utils/python/local_typing.py
index 1a4f07dc39d537011f01428cb1d120d34dd02208..0ae53817866924f16e74b0da9b471ccb715f1c01 100644 (file)
@@ -579,6 +579,7 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f
 {
        auto_source_discovery_internal_status status;
        GError *error = NULL;
+       GDir *dir = NULL;
 
        if (g_file_test(input->str, G_FILE_TEST_IS_REGULAR)) {
                /* It's a file. */
@@ -587,7 +588,6 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f
                        component_class_restrict, log_level, auto_disc,
                        interrupter);
        } else if (g_file_test(input->str, G_FILE_TEST_IS_DIR)) {
-               GDir *dir;
                const gchar *dirent;
                gsize saved_input_len;
                int dir_status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_NO_MATCH;
@@ -658,8 +658,6 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f
                } while (dirent);
 
                status = dir_status;
-
-               g_dir_close(dir);
        } else {
                BT_LOGD("Skipping %s, not a file or directory", input->str);
                status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_NO_MATCH;
@@ -671,6 +669,9 @@ error:
        status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_ERROR;
 
 end:
+       if (dir) {
+               g_dir_close(dir);
+       }
 
        if (error) {
                g_error_free(error);
index c8e3eb44ae99e391fba19fccd46b1d7048a00a9a..6b31a743391c52eae99f471cf9b3bb509c84fbb4 100644 (file)
@@ -119,6 +119,9 @@ WARN_CFLAGS += -Wno-null-dereference
 # code.
 WARN_CFLAGS += -Wno-deprecated-declarations
 
+# Python 3.11 + gcc 12.2.0 gave warnings of this kind in Python.h.
+WARN_CFLAGS += -Wno-redundant-decls
+
 BUILD_FLAGS=CC="$(CC)" \
                CFLAGS="$(GLIB_CFLAGS) $(AM_CFLAGS) $(CFLAGS) $(WARN_CFLAGS)" \
                CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS) -I$(srcdir)/bt2" \
@@ -148,8 +151,12 @@ $(builddir)/bt2/native_bt.c: $(SWIG_INTERFACE_FILES)
 
 -include bt2/native_bt.d
 
+pyinstall_verbose = $(pyinstall_verbose_@AM_V@)
+pyinstall_verbose_ = $(pyinstall_verbose_@AM_DEFAULT_V@)
+pyinstall_verbose_0 = @
+
 install-exec-local: build-python-bindings.stamp
-       @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
+       $(pyinstall_verbose)opts="--prefix=$(prefix) --exec-prefix=$(exec_prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
        if [ "$(DESTDIR)" != "" ]; then \
                opts="$$opts --root=$(DESTDIR)"; \
        fi; \
index 38bb9b17dad280e7ead2a481ff204ae0a9dd6f02..089c98b076191e52638bf63a2da9bad0c9617efd 100644 (file)
 
 import sys
 
+from bt2.mip import get_maximal_mip_version, get_greatest_operative_mip_version
+from bt2.error import (
+    ComponentClassType,
+    _Error,
+    _ErrorCause,
+    _MemoryError,
+    _ComponentErrorCause,
+    _ComponentClassErrorCause,
+    _MessageIteratorErrorCause,
+)
+from bt2.field import (
+    _BoolField,
+    _RealField,
+    _ArrayField,
+    _OptionField,
+    _StringField,
+    _IntegerField,
+    _VariantField,
+    _BitArrayField,
+    _BoolFieldConst,
+    _RealFieldConst,
+    _StructureField,
+    _ArrayFieldConst,
+    _EnumerationField,
+    _OptionFieldConst,
+    _StaticArrayField,
+    _StringFieldConst,
+    _DynamicArrayField,
+    _IntegerFieldConst,
+    _VariantFieldConst,
+    _BitArrayFieldConst,
+    _SignedIntegerField,
+    _StructureFieldConst,
+    _UnsignedIntegerField,
+    _EnumerationFieldConst,
+    _StaticArrayFieldConst,
+    _DynamicArrayFieldConst,
+    _SignedEnumerationField,
+    _SignedIntegerFieldConst,
+    _DoublePrecisionRealField,
+    _SinglePrecisionRealField,
+    _UnsignedEnumerationField,
+    _UnsignedIntegerFieldConst,
+    _SignedEnumerationFieldConst,
+    _DoublePrecisionRealFieldConst,
+    _SinglePrecisionRealFieldConst,
+    _UnsignedEnumerationFieldConst,
+)
+from bt2.graph import Graph
+from bt2.utils import Stop, TryAgain, UnknownObject, _OverflowError
+from bt2.value import (
+    MapValue,
+    BoolValue,
+    RealValue,
+    ArrayValue,
+    StringValue,
+    SignedIntegerValue,
+    UnsignedIntegerValue,
+    create_value,
+    _IntegerValue,
+    _MapValueConst,
+    _BoolValueConst,
+    _RealValueConst,
+    _ArrayValueConst,
+    _StringValueConst,
+    _IntegerValueConst,
+    _SignedIntegerValueConst,
+    _UnsignedIntegerValueConst,
+)
+from bt2.plugin import find_plugin, find_plugins, find_plugins_in_path
+from bt2.logging import (
+    LoggingLevel,
+    get_global_logging_level,
+    set_global_logging_level,
+    get_minimal_logging_level,
+)
+from bt2.message import (
+    _EventMessage,
+    _PacketEndMessage,
+    _StreamEndMessage,
+    _EventMessageConst,
+    _PacketEndMessageConst,
+    _StreamEndMessageConst,
+    _DiscardedEventsMessage,
+    _PacketBeginningMessage,
+    _StreamBeginningMessage,
+    _DiscardedPacketsMessage,
+    _DiscardedEventsMessageConst,
+    _PacketBeginningMessageConst,
+    _StreamBeginningMessageConst,
+    _DiscardedPacketsMessageConst,
+    _MessageIteratorInactivityMessage,
+    _MessageIteratorInactivityMessageConst,
+)
+from bt2.version import __version__
+from bt2.component import (
+    _UserSinkComponent,
+    _SinkComponentConst,
+    _IncompleteUserClass,
+    _UserFilterComponent,
+    _UserSourceComponent,
+    _FilterComponentConst,
+    _SourceComponentConst,
+    _SinkComponentClassConst,
+    _FilterComponentClassConst,
+    _SourceComponentClassConst,
+)
+from bt2.py_plugin import register_plugin, plugin_component_class
+from bt2.field_path import (
+    FieldPathScope,
+    _IndexFieldPathItem,
+    _CurrentArrayElementFieldPathItem,
+    _CurrentOptionContentFieldPathItem,
+)
+
 # import all public names
 from bt2.clock_class import ClockClassOffset
-from bt2.clock_snapshot import _ClockSnapshotConst
-from bt2.clock_snapshot import _UnknownClockSnapshot
-from bt2.component import _SourceComponentClassConst
-from bt2.component import _FilterComponentClassConst
-from bt2.component import _SinkComponentClassConst
-from bt2.component import _SourceComponentConst
-from bt2.component import _FilterComponentConst
-from bt2.component import _SinkComponentConst
-from bt2.component import _UserSourceComponent
-from bt2.component import _UserFilterComponent
-from bt2.component import _UserSinkComponent
-from bt2.component_descriptor import ComponentDescriptor
-from bt2.error import ComponentClassType
-from bt2.error import _ErrorCause
-from bt2.error import _ComponentErrorCause
-from bt2.error import _ComponentClassErrorCause
-from bt2.error import _MessageIteratorErrorCause
-from bt2.error import _Error
 from bt2.event_class import EventClassLogLevel
-from bt2.field import _BoolField
-from bt2.field import _BitArrayField
-from bt2.field import _IntegerField
-from bt2.field import _UnsignedIntegerField
-from bt2.field import _SignedIntegerField
-from bt2.field import _RealField
-from bt2.field import _SinglePrecisionRealField
-from bt2.field import _DoublePrecisionRealField
-from bt2.field import _EnumerationField
-from bt2.field import _UnsignedEnumerationField
-from bt2.field import _SignedEnumerationField
-from bt2.field import _StringField
-from bt2.field import _StructureField
-from bt2.field import _OptionField
-from bt2.field import _VariantField
-from bt2.field import _ArrayField
-from bt2.field import _StaticArrayField
-from bt2.field import _DynamicArrayField
-from bt2.field import _BoolFieldConst
-from bt2.field import _BitArrayFieldConst
-from bt2.field import _IntegerFieldConst
-from bt2.field import _UnsignedIntegerFieldConst
-from bt2.field import _SignedIntegerFieldConst
-from bt2.field import _RealFieldConst
-from bt2.field import _SinglePrecisionRealFieldConst
-from bt2.field import _DoublePrecisionRealFieldConst
-from bt2.field import _EnumerationFieldConst
-from bt2.field import _UnsignedEnumerationFieldConst
-from bt2.field import _SignedEnumerationFieldConst
-from bt2.field import _StringFieldConst
-from bt2.field import _StructureFieldConst
-from bt2.field import _OptionFieldConst
-from bt2.field import _VariantFieldConst
-from bt2.field import _ArrayFieldConst
-from bt2.field import _StaticArrayFieldConst
-from bt2.field import _DynamicArrayFieldConst
-from bt2.field_class import IntegerDisplayBase
-from bt2.field_class import _BoolFieldClass
-from bt2.field_class import _BitArrayFieldClass
-from bt2.field_class import _IntegerFieldClass
-from bt2.field_class import _UnsignedIntegerFieldClass
-from bt2.field_class import _SignedIntegerFieldClass
-from bt2.field_class import _RealFieldClass
-from bt2.field_class import _EnumerationFieldClass
-from bt2.field_class import _UnsignedEnumerationFieldClass
-from bt2.field_class import _SignedEnumerationFieldClass
-from bt2.field_class import _StringFieldClass
-from bt2.field_class import _StructureFieldClass
-from bt2.field_class import _OptionFieldClass
-from bt2.field_class import _OptionWithSelectorFieldClass
-from bt2.field_class import _OptionWithBoolSelectorFieldClass
-from bt2.field_class import _OptionWithIntegerSelectorFieldClass
-from bt2.field_class import _OptionWithUnsignedIntegerSelectorFieldClass
-from bt2.field_class import _OptionWithSignedIntegerSelectorFieldClass
-from bt2.field_class import _VariantFieldClass
-from bt2.field_class import _VariantFieldClassWithoutSelector
-from bt2.field_class import _VariantFieldClassWithIntegerSelector
-from bt2.field_class import _VariantFieldClassWithUnsignedIntegerSelector
-from bt2.field_class import _VariantFieldClassWithSignedIntegerSelector
-from bt2.field_class import _ArrayFieldClass
-from bt2.field_class import _StaticArrayFieldClass
-from bt2.field_class import _DynamicArrayFieldClass
-from bt2.field_class import _DynamicArrayWithLengthFieldFieldClass
-from bt2.field_class import _BoolFieldClassConst
-from bt2.field_class import _BitArrayFieldClassConst
-from bt2.field_class import _IntegerFieldClassConst
-from bt2.field_class import _UnsignedIntegerFieldClassConst
-from bt2.field_class import _SignedIntegerFieldClassConst
-from bt2.field_class import _RealFieldClassConst
-from bt2.field_class import _EnumerationFieldClassConst
-from bt2.field_class import _UnsignedEnumerationFieldClassConst
-from bt2.field_class import _SignedEnumerationFieldClassConst
-from bt2.field_class import _StringFieldClassConst
-from bt2.field_class import _StructureFieldClassConst
-from bt2.field_class import _OptionFieldClassConst
-from bt2.field_class import _OptionWithSelectorFieldClassConst
-from bt2.field_class import _OptionWithBoolSelectorFieldClassConst
-from bt2.field_class import _OptionWithIntegerSelectorFieldClassConst
-from bt2.field_class import _OptionWithUnsignedIntegerSelectorFieldClassConst
-from bt2.field_class import _OptionWithSignedIntegerSelectorFieldClassConst
-from bt2.field_class import _VariantFieldClassConst
-from bt2.field_class import _VariantFieldClassWithoutSelectorConst
-from bt2.field_class import _VariantFieldClassWithIntegerSelectorConst
-from bt2.field_class import _VariantFieldClassWithUnsignedIntegerSelectorConst
-from bt2.field_class import _VariantFieldClassWithSignedIntegerSelectorConst
-from bt2.field_class import _ArrayFieldClassConst
-from bt2.field_class import _StaticArrayFieldClassConst
-from bt2.field_class import _DynamicArrayFieldClassConst
-from bt2.field_class import _DynamicArrayWithLengthFieldFieldClassConst
-from bt2.field_path import FieldPathScope
-from bt2.field_path import _IndexFieldPathItem
-from bt2.field_path import _CurrentArrayElementFieldPathItem
-from bt2.field_path import _CurrentOptionContentFieldPathItem
-from bt2.graph import Graph
-from bt2.integer_range_set import SignedIntegerRange
-from bt2.integer_range_set import UnsignedIntegerRange
-from bt2.integer_range_set import SignedIntegerRangeSet
-from bt2.integer_range_set import UnsignedIntegerRangeSet
-from bt2.integer_range_set import _SignedIntegerRangeConst
-from bt2.integer_range_set import _UnsignedIntegerRangeConst
-from bt2.integer_range_set import _SignedIntegerRangeSetConst
-from bt2.integer_range_set import _UnsignedIntegerRangeSetConst
+from bt2.field_class import (
+    IntegerDisplayBase,
+    _BoolFieldClass,
+    _RealFieldClass,
+    _ArrayFieldClass,
+    _OptionFieldClass,
+    _StringFieldClass,
+    _IntegerFieldClass,
+    _VariantFieldClass,
+    _BitArrayFieldClass,
+    _BoolFieldClassConst,
+    _RealFieldClassConst,
+    _StructureFieldClass,
+    _ArrayFieldClassConst,
+    _EnumerationFieldClass,
+    _OptionFieldClassConst,
+    _StaticArrayFieldClass,
+    _StringFieldClassConst,
+    _DynamicArrayFieldClass,
+    _IntegerFieldClassConst,
+    _VariantFieldClassConst,
+    _BitArrayFieldClassConst,
+    _SignedIntegerFieldClass,
+    _StructureFieldClassConst,
+    _UnsignedIntegerFieldClass,
+    _EnumerationFieldClassConst,
+    _StaticArrayFieldClassConst,
+    _DynamicArrayFieldClassConst,
+    _SignedEnumerationFieldClass,
+    _OptionWithSelectorFieldClass,
+    _SignedIntegerFieldClassConst,
+    _UnsignedEnumerationFieldClass,
+    _UnsignedIntegerFieldClassConst,
+    _OptionWithBoolSelectorFieldClass,
+    _SignedEnumerationFieldClassConst,
+    _VariantFieldClassWithoutSelector,
+    _OptionWithSelectorFieldClassConst,
+    _UnsignedEnumerationFieldClassConst,
+    _OptionWithIntegerSelectorFieldClass,
+    _VariantFieldClassWithIntegerSelector,
+    _DynamicArrayWithLengthFieldFieldClass,
+    _OptionWithBoolSelectorFieldClassConst,
+    _VariantFieldClassWithoutSelectorConst,
+    _OptionWithIntegerSelectorFieldClassConst,
+    _OptionWithSignedIntegerSelectorFieldClass,
+    _VariantFieldClassWithIntegerSelectorConst,
+    _DynamicArrayWithLengthFieldFieldClassConst,
+    _VariantFieldClassWithSignedIntegerSelector,
+    _OptionWithUnsignedIntegerSelectorFieldClass,
+    _VariantFieldClassWithUnsignedIntegerSelector,
+    _OptionWithSignedIntegerSelectorFieldClassConst,
+    _VariantFieldClassWithSignedIntegerSelectorConst,
+    _OptionWithUnsignedIntegerSelectorFieldClassConst,
+    _VariantFieldClassWithUnsignedIntegerSelectorConst,
+)
 from bt2.interrupter import Interrupter
-from bt2.logging import LoggingLevel
-from bt2.logging import get_minimal_logging_level
-from bt2.logging import get_global_logging_level
-from bt2.logging import set_global_logging_level
-from bt2.message import _EventMessage
-from bt2.message import _PacketBeginningMessage
-from bt2.message import _PacketEndMessage
-from bt2.message import _StreamBeginningMessage
-from bt2.message import _StreamEndMessage
-from bt2.message import _MessageIteratorInactivityMessage
-from bt2.message import _DiscardedEventsMessage
-from bt2.message import _DiscardedPacketsMessage
-from bt2.message import _EventMessageConst
-from bt2.message import _PacketBeginningMessageConst
-from bt2.message import _PacketEndMessageConst
-from bt2.message import _StreamBeginningMessageConst
-from bt2.message import _StreamEndMessageConst
-from bt2.message import _MessageIteratorInactivityMessageConst
-from bt2.message import _DiscardedEventsMessageConst
-from bt2.message import _DiscardedPacketsMessageConst
-from bt2.message_iterator import _UserMessageIterator
-from bt2.mip import get_greatest_operative_mip_version
-from bt2.mip import get_maximal_mip_version
-from bt2.plugin import find_plugins_in_path
-from bt2.plugin import find_plugins
-from bt2.plugin import find_plugin
-from bt2.py_plugin import plugin_component_class
-from bt2.py_plugin import register_plugin
+from bt2.clock_snapshot import _ClockSnapshotConst, _UnknownClockSnapshot
 from bt2.query_executor import QueryExecutor
-from bt2.trace_collection_message_iterator import AutoSourceComponentSpec
-from bt2.trace_collection_message_iterator import ComponentSpec
-from bt2.trace_collection_message_iterator import TraceCollectionMessageIterator
-from bt2.value import create_value
-from bt2.value import BoolValue
-from bt2.value import _IntegerValue
-from bt2.value import UnsignedIntegerValue
-from bt2.value import SignedIntegerValue
-from bt2.value import RealValue
-from bt2.value import StringValue
-from bt2.value import ArrayValue
-from bt2.value import MapValue
-from bt2.value import _BoolValueConst
-from bt2.value import _IntegerValueConst
-from bt2.value import _UnsignedIntegerValueConst
-from bt2.value import _SignedIntegerValueConst
-from bt2.value import _RealValueConst
-from bt2.value import _StringValueConst
-from bt2.value import _ArrayValueConst
-from bt2.value import _MapValueConst
-from bt2.version import __version__
+from bt2.message_iterator import _UserMessageIterator
+from bt2.integer_range_set import (
+    SignedIntegerRange,
+    UnsignedIntegerRange,
+    SignedIntegerRangeSet,
+    UnsignedIntegerRangeSet,
+    _SignedIntegerRangeConst,
+    _UnsignedIntegerRangeConst,
+    _SignedIntegerRangeSetConst,
+    _UnsignedIntegerRangeSetConst,
+)
+from bt2.component_descriptor import ComponentDescriptor
+from bt2.trace_collection_message_iterator import (
+    ComponentSpec,
+    AutoSourceComponentSpec,
+    TraceCollectionMessageIterator,
+)
 
 if (sys.version_info.major, sys.version_info.minor) != (3, 4):
 
@@ -227,39 +246,11 @@ if (sys.version_info.major, sys.version_info.minor) != (3, 4):
 del sys
 
 
-class _MemoryError(_Error):
-    """Raised when an operation fails due to memory issues."""
-
-
-class UnknownObject(Exception):
-    """
-    Raised when a component class handles a query for an object it doesn't
-    know about.
-    """
-
-    pass
-
-
-class _OverflowError(_Error, OverflowError):
-    pass
-
-
-class TryAgain(Exception):
-    pass
-
-
-class Stop(StopIteration):
-    pass
-
-
-class _IncompleteUserClass(Exception):
-    pass
-
-
 def _init_and_register_exit():
-    from bt2 import native_bt
     import atexit
 
+    from bt2 import native_bt
+
     atexit.register(native_bt.bt2_exit_handler)
     native_bt.bt2_init_from_bt2()
 
index 4cdea396be2b77939470090b2308fa5d7c47568c..c7527c7722d91bc447b70807df3d24c870484270 100644 (file)
@@ -2,15 +2,18 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import value as bt2_value
 import uuid as uuidp
 
+from bt2 import utils as bt2_utils
+from bt2 import value as bt2_value
+from bt2 import object as bt2_object
+from bt2 import native_bt
+
 
 class ClockClassOffset:
     def __init__(self, seconds=0, cycles=0):
-        utils._check_int64(seconds)
-        utils._check_int64(cycles)
+        bt2_utils._check_int64(seconds)
+        bt2_utils._check_int64(cycles)
         self._seconds = seconds
         self._cycles = cycles
 
@@ -30,9 +33,15 @@ class ClockClassOffset:
         return (self.seconds, self.cycles) == (other.seconds, other.cycles)
 
 
-class _ClockClassConst(object._SharedObject):
-    _get_ref = staticmethod(native_bt.clock_class_get_ref)
-    _put_ref = staticmethod(native_bt.clock_class_put_ref)
+class _ClockClassConst(bt2_object._SharedObject):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.clock_class_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.clock_class_put_ref(ptr)
+
     _create_value_from_ptr_and_get_ref = staticmethod(
         bt2_value._create_from_const_ptr_and_get_ref
     )
@@ -82,10 +91,10 @@ class _ClockClassConst(object._SharedObject):
         return uuidp.UUID(bytes=uuid_bytes)
 
     def cycles_to_ns_from_origin(self, cycles):
-        utils._check_uint64(cycles)
+        bt2_utils._check_uint64(cycles)
         status, ns = native_bt.clock_class_cycles_to_ns_from_origin(self._ptr, cycles)
         error_msg = "cannot convert clock value to nanoseconds from origin for given clock class"
-        utils._handle_func_status(status, error_msg)
+        bt2_utils._handle_func_status(status, error_msg)
         return ns
 
 
@@ -99,45 +108,47 @@ class _ClockClass(_ClockClassConst):
 
     def _user_attributes(self, user_attributes):
         value = bt2_value.create_value(user_attributes)
-        utils._check_type(value, bt2_value.MapValue)
+        bt2_utils._check_type(value, bt2_value.MapValue)
         native_bt.clock_class_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
 
     def _name(self, name):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
         status = native_bt.clock_class_set_name(self._ptr, name)
-        utils._handle_func_status(status, "cannot set clock class object's name")
+        bt2_utils._handle_func_status(status, "cannot set clock class object's name")
 
     _name = property(fset=_name)
 
     def _description(self, description):
-        utils._check_str(description)
+        bt2_utils._check_str(description)
         status = native_bt.clock_class_set_description(self._ptr, description)
-        utils._handle_func_status(status, "cannot set clock class object's description")
+        bt2_utils._handle_func_status(
+            status, "cannot set clock class object's description"
+        )
 
     _description = property(fset=_description)
 
     def _frequency(self, frequency):
-        utils._check_uint64(frequency)
+        bt2_utils._check_uint64(frequency)
         native_bt.clock_class_set_frequency(self._ptr, frequency)
 
     _frequency = property(fset=_frequency)
 
     def _precision(self, precision):
-        utils._check_uint64(precision)
+        bt2_utils._check_uint64(precision)
         native_bt.clock_class_set_precision(self._ptr, precision)
 
     _precision = property(fset=_precision)
 
     def _offset(self, offset):
-        utils._check_type(offset, ClockClassOffset)
+        bt2_utils._check_type(offset, ClockClassOffset)
         native_bt.clock_class_set_offset(self._ptr, offset.seconds, offset.cycles)
 
     _offset = property(fset=_offset)
 
     def _origin_is_unix_epoch(self, origin_is_unix_epoch):
-        utils._check_bool(origin_is_unix_epoch)
+        bt2_utils._check_bool(origin_is_unix_epoch)
         native_bt.clock_class_set_origin_is_unix_epoch(
             self._ptr, int(origin_is_unix_epoch)
         )
@@ -145,7 +156,7 @@ class _ClockClass(_ClockClassConst):
     _origin_is_unix_epoch = property(fset=_origin_is_unix_epoch)
 
     def _uuid(self, uuid):
-        utils._check_type(uuid, uuidp.UUID)
+        bt2_utils._check_type(uuid, uuidp.UUID)
         native_bt.clock_class_set_uuid(self._ptr, uuid.bytes)
 
     _uuid = property(fset=_uuid)
index 6c2e3285e04ce13679dbcd817982a4384531a291..82591463de7fb99373f77b9bcd7fd7c8bc3f01e1 100644 (file)
@@ -2,14 +2,17 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
 import numbers
-from bt2 import clock_class as bt2_clock_class
 import functools
 
+from bt2 import utils as bt2_utils
+from bt2 import object as bt2_object
+from bt2 import native_bt
+from bt2 import clock_class as bt2_clock_class
+
 
 @functools.total_ordering
-class _ClockSnapshotConst(object._UniqueObject):
+class _ClockSnapshotConst(bt2_object._UniqueObject):
     @property
     def clock_class(self):
         cc_ptr = native_bt.clock_snapshot_borrow_clock_class_const(self._ptr)
@@ -23,7 +26,7 @@ class _ClockSnapshotConst(object._UniqueObject):
     @property
     def ns_from_origin(self):
         status, ns = native_bt.clock_snapshot_get_ns_from_origin(self._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot get clock snapshot's nanoseconds from origin"
         )
         return ns
index 7ae6fe25cee9124a017fc72485009d1a87e38254..30f0849c7c4d4ce066eb25cd60f2c651a44678ea 100644 (file)
@@ -2,16 +2,24 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import message_iterator as bt2_message_iterator
+import sys
 import collections.abc
+
+from bt2 import port as bt2_port
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
 from bt2 import value as bt2_value
-from bt2 import trace_class as bt2_trace_class
+from bt2 import object as bt2_object
+from bt2 import native_bt
 from bt2 import clock_class as bt2_clock_class
+from bt2 import trace_class as bt2_trace_class
 from bt2 import query_executor as bt2_query_executor
-from bt2 import port as bt2_port
-import sys
-import bt2
+from bt2 import message_iterator as bt2_message_iterator
+from bt2 import integer_range_set as bt2_integer_range_set
+
+
+class _IncompleteUserClass(Exception):
+    pass
 
 
 # This class wraps a component class pointer. This component class could
@@ -25,7 +33,7 @@ import bt2
 #     pointer to a 'bt_component_class *'.
 
 
-class _ComponentClassConst(object._SharedObject):
+class _ComponentClassConst(bt2_object._SharedObject):
     @property
     def name(self):
         ptr = self._bt_as_component_class_ptr(self._ptr)
@@ -58,24 +66,42 @@ class _ComponentClassConst(object._SharedObject):
 
 
 class _SourceComponentClassConst(_ComponentClassConst):
-    _get_ref = staticmethod(native_bt.component_class_source_get_ref)
-    _put_ref = staticmethod(native_bt.component_class_source_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.component_class_source_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.component_class_source_put_ref(ptr)
+
     _bt_as_component_class_ptr = staticmethod(
         native_bt.component_class_source_as_component_class
     )
 
 
 class _FilterComponentClassConst(_ComponentClassConst):
-    _get_ref = staticmethod(native_bt.component_class_filter_get_ref)
-    _put_ref = staticmethod(native_bt.component_class_filter_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.component_class_filter_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.component_class_filter_put_ref(ptr)
+
     _bt_as_component_class_ptr = staticmethod(
         native_bt.component_class_filter_as_component_class
     )
 
 
 class _SinkComponentClassConst(_ComponentClassConst):
-    _get_ref = staticmethod(native_bt.component_class_sink_get_ref)
-    _put_ref = staticmethod(native_bt.component_class_sink_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.component_class_sink_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.component_class_sink_put_ref(ptr)
+
     _bt_as_component_class_ptr = staticmethod(
         native_bt.component_class_sink_as_component_class
     )
@@ -104,7 +130,6 @@ class _PortIterator(collections.abc.Iterator):
 
 
 class _ComponentPorts(collections.abc.Mapping):
-
     # component_ptr is a bt_component_source *, bt_component_filter * or
     # bt_component_sink *.  Its type must match the type expected by the
     # functions passed as arguments.
@@ -124,7 +149,7 @@ class _ComponentPorts(collections.abc.Mapping):
         self._port_pycls = port_pycls
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
         port_ptr = self._borrow_port_ptr_by_name(self._component_ptr, key)
 
         if port_ptr is None:
@@ -218,9 +243,14 @@ class _SinkComponentConst(_ComponentConst):
 
 # This is analogous to _SourceComponentClassConst, but for source
 # component objects.
-class _GenericSourceComponentConst(object._SharedObject, _SourceComponentConst):
-    _get_ref = staticmethod(native_bt.component_source_get_ref)
-    _put_ref = staticmethod(native_bt.component_source_put_ref)
+class _GenericSourceComponentConst(bt2_object._SharedObject, _SourceComponentConst):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.component_source_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.component_source_put_ref(ptr)
 
     @property
     def output_ports(self):
@@ -235,9 +265,14 @@ class _GenericSourceComponentConst(object._SharedObject, _SourceComponentConst):
 
 # This is analogous to _FilterComponentClassConst, but for filter
 # component objects.
-class _GenericFilterComponentConst(object._SharedObject, _FilterComponentConst):
-    _get_ref = staticmethod(native_bt.component_filter_get_ref)
-    _put_ref = staticmethod(native_bt.component_filter_put_ref)
+class _GenericFilterComponentConst(bt2_object._SharedObject, _FilterComponentConst):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.component_filter_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.component_filter_put_ref(ptr)
 
     @property
     def output_ports(self):
@@ -262,9 +297,14 @@ class _GenericFilterComponentConst(object._SharedObject, _FilterComponentConst):
 
 # This is analogous to _SinkComponentClassConst, but for sink
 # component objects.
-class _GenericSinkComponentConst(object._SharedObject, _SinkComponentConst):
-    _get_ref = staticmethod(native_bt.component_sink_get_ref)
-    _put_ref = staticmethod(native_bt.component_sink_put_ref)
+class _GenericSinkComponentConst(bt2_object._SharedObject, _SinkComponentConst):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.component_sink_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.component_sink_put_ref(ptr)
 
     @property
     def input_ports(self):
@@ -448,12 +488,12 @@ class _UserComponentType(type):
             return
 
         comp_cls_name = kwargs.get("name", class_name)
-        utils._check_str(comp_cls_name)
+        bt2_utils._check_str(comp_cls_name)
         comp_cls_descr = None
         comp_cls_help = None
 
         if hasattr(cls, "__doc__") and cls.__doc__ is not None:
-            utils._check_str(cls.__doc__)
+            bt2_utils._check_str(cls.__doc__)
             docstring = _trim_docstring(cls.__doc__)
             lines = docstring.splitlines()
 
@@ -477,7 +517,7 @@ class _UserComponentType(type):
             )
         elif _UserSinkComponent in bases:
             if not hasattr(cls, "_user_consume"):
-                raise bt2._IncompleteUserClass(
+                raise _IncompleteUserClass(
                     "cannot create component class '{}': missing a _user_consume() method".format(
                         class_name
                     )
@@ -487,14 +527,14 @@ class _UserComponentType(type):
                 cls, comp_cls_name, comp_cls_descr, comp_cls_help
             )
         else:
-            raise bt2._IncompleteUserClass(
+            raise _IncompleteUserClass(
                 "cannot find a known component class base in the bases of '{}'".format(
                     class_name
                 )
             )
 
         if cc_ptr is None:
-            raise bt2._MemoryError(
+            raise bt2_error._MemoryError(
                 "cannot create component class '{}'".format(class_name)
             )
 
@@ -527,21 +567,21 @@ class _UserComponentType(type):
     @staticmethod
     def _bt_set_iterator_class(cls, iter_cls):
         if iter_cls is None:
-            raise bt2._IncompleteUserClass(
+            raise _IncompleteUserClass(
                 "cannot create component class '{}': missing message iterator class".format(
                     cls.__name__
                 )
             )
 
         if not issubclass(iter_cls, bt2_message_iterator._UserMessageIterator):
-            raise bt2._IncompleteUserClass(
+            raise _IncompleteUserClass(
                 "cannot create component class '{}': message iterator class does not inherit bt2._UserMessageIterator".format(
                     cls.__name__
                 )
             )
 
         if not hasattr(iter_cls, "__next__"):
-            raise bt2._IncompleteUserClass(
+            raise _IncompleteUserClass(
                 "cannot create component class '{}': message iterator class is missing a __next__() method".format(
                     cls.__name__
                 )
@@ -550,7 +590,7 @@ class _UserComponentType(type):
         if hasattr(iter_cls, "_user_can_seek_ns_from_origin") and not hasattr(
             iter_cls, "_user_seek_ns_from_origin"
         ):
-            raise bt2._IncompleteUserClass(
+            raise _IncompleteUserClass(
                 "cannot create component class '{}': message iterator class implements _user_can_seek_ns_from_origin but not _user_seek_ns_from_origin".format(
                     cls.__name__
                 )
@@ -559,7 +599,7 @@ class _UserComponentType(type):
         if hasattr(iter_cls, "_user_can_seek_beginning") and not hasattr(
             iter_cls, "_user_seek_beginning"
         ):
-            raise bt2._IncompleteUserClass(
+            raise _IncompleteUserClass(
                 "cannot create component class '{}': message iterator class implements _user_can_seek_beginning but not _user_seek_beginning".format(
                     cls.__name__
                 )
@@ -596,9 +636,9 @@ class _UserComponentType(type):
         # this can raise, but the native side checks the exception
         range_set = cls._user_get_supported_mip_versions(params, obj, log_level)
 
-        if type(range_set) is not bt2.UnsignedIntegerRangeSet:
+        if type(range_set) is not bt2_integer_range_set.UnsignedIntegerRangeSet:
             # this can raise, but the native side checks the exception
-            range_set = bt2.UnsignedIntegerRangeSet(range_set)
+            range_set = bt2_integer_range_set.UnsignedIntegerRangeSet(range_set)
 
         # return new reference
         range_set._get_ref(range_set._ptr)
@@ -631,7 +671,7 @@ class _UserComponentType(type):
             priv_query_exec._invalidate()
 
         # this can raise, but the native side checks the exception
-        results = bt2.create_value(results)
+        results = bt2_value.create_value(results)
 
         if results is None:
             results_ptr = native_bt.value_null
@@ -643,7 +683,7 @@ class _UserComponentType(type):
         return int(results_ptr)
 
     def _user_query(cls, priv_query_executor, object_name, params, method_obj):
-        raise bt2.UnknownObject
+        raise bt2_utils.UnknownObject
 
     def _bt_component_class_ptr(self):
         return self._bt_as_component_class_ptr(self._bt_cc_ptr)
@@ -753,7 +793,7 @@ class _UserComponent(metaclass=_UserComponentType):
         tc_ptr = native_bt.trace_class_create(ptr)
 
         if tc_ptr is None:
-            raise bt2._MemoryError("could not create trace class")
+            raise bt2_error._MemoryError("could not create trace class")
 
         tc = bt2_trace_class._TraceClass._create_from_ptr(tc_ptr)
         tc._assigns_automatic_stream_class_id = assigns_automatic_stream_class_id
@@ -778,7 +818,7 @@ class _UserComponent(metaclass=_UserComponentType):
         cc_ptr = native_bt.clock_class_create(ptr)
 
         if cc_ptr is None:
-            raise bt2._MemoryError("could not create clock class")
+            raise bt2_error._MemoryError("could not create clock class")
 
         cc = bt2_clock_class._ClockClass._create_from_ptr(cc_ptr)
 
@@ -832,7 +872,7 @@ class _UserSourceComponent(_UserComponent, _SourceComponentConst):
         )
 
     def _add_output_port(self, name, user_data=None):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
 
         if name in self._output_ports:
             raise ValueError(
@@ -843,7 +883,7 @@ class _UserSourceComponent(_UserComponent, _SourceComponentConst):
 
         fn = native_bt.self_component_source_add_output_port
         comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             comp_status, "cannot add output port to source component object"
         )
         assert self_port_ptr is not None
@@ -890,7 +930,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst):
         )
 
     def _add_output_port(self, name, user_data=None):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
 
         if name in self._output_ports:
             raise ValueError(
@@ -901,7 +941,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst):
 
         fn = native_bt.self_component_filter_add_output_port
         comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             comp_status, "cannot add output port to filter component object"
         )
         assert self_port_ptr
@@ -910,7 +950,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst):
         )
 
     def _add_input_port(self, name, user_data=None):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
 
         if name in self._input_ports:
             raise ValueError(
@@ -921,7 +961,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst):
 
         fn = native_bt.self_component_filter_add_input_port
         comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             comp_status, "cannot add input port to filter component object"
         )
         assert self_port_ptr
@@ -960,7 +1000,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst):
         )
 
     def _add_input_port(self, name, user_data=None):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
 
         if name in self._input_ports:
             raise ValueError(
@@ -971,7 +1011,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst):
 
         fn = native_bt.self_component_sink_add_input_port
         comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             comp_status, "cannot add input port to sink component object"
         )
         assert self_port_ptr
@@ -980,7 +1020,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst):
         )
 
     def _create_message_iterator(self, input_port):
-        utils._check_type(input_port, bt2_port._UserComponentInputPort)
+        bt2_utils._check_type(input_port, bt2_port._UserComponentInputPort)
 
         if not input_port.is_connected:
             raise ValueError("input port is not connected")
@@ -991,7 +1031,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst):
         ) = native_bt.bt2_message_iterator_create_from_sink_component(
             self._bt_ptr, input_port._ptr
         )
-        utils._handle_func_status(status, "cannot create message iterator object")
+        bt2_utils._handle_func_status(status, "cannot create message iterator object")
         assert msg_iter_ptr is not None
 
         return bt2_message_iterator._UserComponentInputPortMessageIterator(msg_iter_ptr)
index c09c98ef521eca5341cf971f6c2dd83ae0fe2051..35179ab7bcdab5f2724411471d5fa900236d1fff 100644 (file)
@@ -2,9 +2,9 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt
+from bt2 import value as bt2_value
 from bt2 import component as bt2_component
-import bt2
+from bt2 import native_bt
 
 
 def _is_source_comp_cls(comp_cls):
@@ -56,7 +56,7 @@ class ComponentDescriptor:
             raise ValueError("cannot pass a Python object to a non-Python component")
 
         self._comp_cls = component_class
-        self._params = bt2.create_value(params)
+        self._params = bt2_value.create_value(params)
         self._obj = obj
 
     @property
index 0f1fce65c8d5c2529b9bfd066b6fb494ce1dbdf6..cdbe271ec109e4f0a05f6f4db05ab6a45c3adf0f 100644 (file)
@@ -2,14 +2,19 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt
 from bt2 import port as bt2_port
 from bt2 import object as bt2_object
+from bt2 import native_bt
 
 
 class _ConnectionConst(bt2_object._SharedObject):
-    _get_ref = staticmethod(native_bt.connection_get_ref)
-    _put_ref = staticmethod(native_bt.connection_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.connection_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.connection_put_ref(ptr)
 
     @property
     def downstream_port(self):
index e07a3f9002d1cb8c9a5fc32660c70e294e3d51ae..b6d0e9e11edbbcf8eadd9e024f6ab8e1520dec67 100644 (file)
@@ -2,9 +2,10 @@
 #
 # Copyright (c) 2019 Simon Marchi <simon.marchi@efficios.com>
 
-from bt2 import native_bt
 from collections import abc
 
+from bt2 import native_bt
+
 
 class ComponentClassType:
     SOURCE = native_bt.COMPONENT_CLASS_TYPE_SOURCE
@@ -219,3 +220,7 @@ class _Error(Exception, abc.Sequence):
 
     def __str__(self):
         return self._str
+
+
+class _MemoryError(_Error):
+    """Raised when an operation fails due to memory issues."""
index 81215a2069a1d398f0c61932a8d1f3a3a9868241..3ff934fda65803a9fd871fc178451382ec8ea3e0 100644 (file)
@@ -2,15 +2,18 @@
 #
 # Copyright (c) 2016-2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import event_class as bt2_event_class
+import collections.abc
+
+from bt2 import field as bt2_field
+from bt2 import utils as bt2_utils
+from bt2 import object as bt2_object
 from bt2 import packet as bt2_packet
 from bt2 import stream as bt2_stream
-from bt2 import field as bt2_field
-import collections.abc
+from bt2 import native_bt
+from bt2 import event_class as bt2_event_class
 
 
-class _EventConst(object._UniqueObject, collections.abc.Mapping):
+class _EventConst(bt2_object._UniqueObject, collections.abc.Mapping):
     _borrow_class_ptr = staticmethod(native_bt.event_borrow_class_const)
     _borrow_packet_ptr = staticmethod(native_bt.event_borrow_packet_const)
     _borrow_stream_ptr = staticmethod(native_bt.event_borrow_stream_const)
@@ -90,7 +93,7 @@ class _EventConst(object._UniqueObject, collections.abc.Mapping):
         )
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
         payload_field = self.payload_field
 
         if payload_field is not None and key in payload_field:
index cbbd807cb4ab78941c6d854cc2709014c3b87eaf..54ca10a6a4bc93336f592ecaddcd4746620d2df8 100644 (file)
@@ -2,9 +2,11 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import field_class as bt2_field_class
+from bt2 import utils as bt2_utils
 from bt2 import value as bt2_value
+from bt2 import object as bt2_object
+from bt2 import native_bt
+from bt2 import field_class as bt2_field_class
 
 
 def _bt2_stream_class():
@@ -31,9 +33,15 @@ class EventClassLogLevel:
     DEBUG = native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG
 
 
-class _EventClassConst(object._SharedObject):
-    _get_ref = staticmethod(native_bt.event_class_get_ref)
-    _put_ref = staticmethod(native_bt.event_class_put_ref)
+class _EventClassConst(bt2_object._SharedObject):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.event_class_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.event_class_put_ref(ptr)
+
     _borrow_stream_class_ptr = staticmethod(
         native_bt.event_class_borrow_stream_class_const
     )
@@ -145,7 +153,7 @@ class _EventClass(_EventClassConst):
 
     def _emf_uri(self, emf_uri):
         status = native_bt.event_class_set_emf_uri(self._ptr, emf_uri)
-        utils._handle_func_status(status, "cannot set event class object's EMF URI")
+        bt2_utils._handle_func_status(status, "cannot set event class object's EMF URI")
 
     _emf_uri = property(fset=_emf_uri)
 
@@ -153,7 +161,7 @@ class _EventClass(_EventClassConst):
         status = native_bt.event_class_set_specific_context_field_class(
             self._ptr, context_field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot set event class object's context field class"
         )
 
@@ -163,7 +171,7 @@ class _EventClass(_EventClassConst):
         status = native_bt.event_class_set_payload_field_class(
             self._ptr, payload_field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot set event class object's payload field class"
         )
 
@@ -179,11 +187,11 @@ class _EventClass(_EventClassConst):
         payload_field_class,
     ):
         if name is not None:
-            utils._check_str(name)
+            bt2_utils._check_str(name)
 
         if user_attributes is not None:
             value = bt2_value.create_value(user_attributes)
-            utils._check_type(value, bt2_value.MapValue)
+            bt2_utils._check_type(value, bt2_value.MapValue)
 
         if log_level is not None:
             log_levels = (
@@ -208,15 +216,17 @@ class _EventClass(_EventClassConst):
                 raise ValueError("'{}' is not a valid log level".format(log_level))
 
         if emf_uri is not None:
-            utils._check_str(emf_uri)
+            bt2_utils._check_str(emf_uri)
 
         if specific_context_field_class is not None:
-            utils._check_type(
+            bt2_utils._check_type(
                 specific_context_field_class, bt2_field_class._StructureFieldClass
             )
 
         if payload_field_class is not None:
-            utils._check_type(payload_field_class, bt2_field_class._StructureFieldClass)
+            bt2_utils._check_type(
+                payload_field_class, bt2_field_class._StructureFieldClass
+            )
 
 
 _EVENT_CLASS_LOG_LEVEL_TO_OBJ = {
index 40ce52c52adc7b47e0dd5e34f67ae525267508dc..b3bdcd54a3ad7984ec13c6bce8ccb52f813fc603 100644 (file)
@@ -2,18 +2,20 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import field_class as bt2_field_class
-import collections.abc
-import functools
-import numbers
 import math
+import numbers
+import functools
+import collections.abc
+
+from bt2 import utils as bt2_utils
+from bt2 import object as bt2_object
+from bt2 import native_bt
+from bt2 import field_class as bt2_field_class
 
 
 def _create_field_from_ptr_template(
     object_map, ptr, owner_ptr, owner_get_ref, owner_put_ref
 ):
-
     field_class_ptr = native_bt.field_borrow_class_const(ptr)
     typeid = native_bt.field_class_get_type(field_class_ptr)
     field = object_map[typeid]._create_from_ptr_and_get_ref(
@@ -50,7 +52,7 @@ def _get_leaf_field(field):
     return field
 
 
-class _FieldConst(object._UniqueObject):
+class _FieldConst(bt2_object._UniqueObject):
     _create_field_from_ptr = staticmethod(_create_field_from_const_ptr)
     _create_field_class_from_ptr_and_get_ref = staticmethod(
         bt2_field_class._create_field_class_from_const_ptr_and_get_ref
@@ -109,7 +111,7 @@ class _BitArrayField(_BitArrayFieldConst, _Field):
     _NAME = "Bit array"
 
     def _value_as_integer(self, value):
-        utils._check_uint64(value)
+        bt2_utils._check_uint64(value)
         native_bt.field_bit_array_set_value_as_integer(self._ptr, value)
 
     value_as_integer = property(
@@ -451,7 +453,7 @@ class _EnumerationFieldConst(_IntegerFieldConst):
     @property
     def labels(self):
         status, labels = self._get_mapping_labels(self._ptr)
-        utils._handle_func_status(status, "cannot get label for enumeration field")
+        bt2_utils._handle_func_status(status, "cannot get label for enumeration field")
 
         assert labels is not None
         return labels
@@ -547,7 +549,7 @@ class _StringField(_StringFieldConst, _Field):
     def __iadd__(self, value):
         value = self._value_to_str(value)
         status = native_bt.field_string_append(self._ptr, value)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot append to string field object's value"
         )
         return self
@@ -621,7 +623,7 @@ class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping):
         return "{{{}}}".format(", ".join(items))
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
         field_ptr = self._borrow_member_field_ptr_by_name(self._ptr, key)
 
         if field_ptr is None:
@@ -632,7 +634,7 @@ class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping):
         )
 
     def member_at_index(self, index):
-        utils._check_uint64(index)
+        bt2_utils._check_uint64(index)
 
         if index >= len(self):
             raise IndexError
@@ -709,7 +711,7 @@ class _OptionField(_OptionFieldConst, _Field):
     _borrow_field_ptr = staticmethod(native_bt.field_option_borrow_field)
 
     def _has_field(self, value):
-        utils._check_bool(value)
+        bt2_utils._check_bool(value)
         native_bt.field_option_set_has_field(self._ptr, value)
 
     has_field = property(fget=_OptionFieldConst.has_field.fget, fset=_has_field)
@@ -887,9 +889,9 @@ class _DynamicArrayField(_DynamicArrayFieldConst, _ArrayField, _Field):
     _NAME = "Dynamic array"
 
     def _set_length(self, length):
-        utils._check_uint64(length)
+        bt2_utils._check_uint64(length)
         status = native_bt.field_array_dynamic_set_length(self._ptr, length)
-        utils._handle_func_status(status, "cannot set dynamic array length")
+        bt2_utils._handle_func_status(status, "cannot set dynamic array length")
 
     length = property(fget=_ArrayField._get_length, fset=_set_length)
 
index eed50140ea3edd878b7efc4205b1a9078263a0bb..8594b496d08609f1e4ea31d7a6bc0bb116572ebc 100644 (file)
@@ -2,12 +2,15 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
 import collections.abc
+
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
+from bt2 import value as bt2_value
+from bt2 import object as bt2_object
+from bt2 import native_bt
 from bt2 import field_path as bt2_field_path
 from bt2 import integer_range_set as bt2_integer_range_set
-from bt2 import value as bt2_value
-import bt2
 
 
 def _obj_type_from_field_class_ptr_template(type_map, ptr):
@@ -44,9 +47,15 @@ class IntegerDisplayBase:
     HEXADECIMAL = native_bt.FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL
 
 
-class _FieldClassConst(object._SharedObject):
-    _get_ref = staticmethod(native_bt.field_class_get_ref)
-    _put_ref = staticmethod(native_bt.field_class_put_ref)
+class _FieldClassConst(bt2_object._SharedObject):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.field_class_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.field_class_put_ref(ptr)
+
     _borrow_user_attributes_ptr = staticmethod(
         native_bt.field_class_borrow_user_attributes_const
     )
@@ -56,7 +65,7 @@ class _FieldClassConst(object._SharedObject):
 
     def _check_create_status(self, ptr):
         if ptr is None:
-            raise bt2._MemoryError(
+            raise bt2_error._MemoryError(
                 "cannot create {} field class object".format(self._NAME.lower())
             )
 
@@ -77,7 +86,7 @@ class _FieldClass(_FieldClassConst):
 
     def _user_attributes(self, user_attributes):
         value = bt2_value.create_value(user_attributes)
-        utils._check_type(value, bt2_value.MapValue)
+        bt2_utils._check_type(value, bt2_value.MapValue)
         native_bt.field_class_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
@@ -128,7 +137,7 @@ class _IntegerFieldClass(_FieldClass, _IntegerFieldClassConst):
     _field_value_range = property(fset=_field_value_range)
 
     def _preferred_display_base(self, base):
-        utils._check_uint64(base)
+        bt2_utils._check_uint64(base)
 
         if base not in (
             IntegerDisplayBase.BINARY,
@@ -239,7 +248,7 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi
         self._check_int_type(value)
 
         status, labels = self._get_mapping_labels_for_value(self._ptr, value)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot get mapping labels for value {}".format(value)
         )
         return [self[label] for label in labels]
@@ -250,7 +259,7 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi
             yield self._mapping_pycls(mapping_ptr).label
 
     def __getitem__(self, label):
-        utils._check_str(label)
+        bt2_utils._check_str(label)
         mapping_ptr = self._borrow_mapping_ptr_by_label(self._ptr, label)
 
         if mapping_ptr is None:
@@ -261,14 +270,14 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi
 
 class _EnumerationFieldClass(_EnumerationFieldClassConst, _IntegerFieldClass):
     def add_mapping(self, label, ranges):
-        utils._check_str(label)
-        utils._check_type(ranges, self._range_set_pycls)
+        bt2_utils._check_str(label)
+        bt2_utils._check_type(ranges, self._range_set_pycls)
 
         if label in self:
             raise ValueError("duplicate mapping label '{}'".format(label))
 
         status = self._add_mapping(self._ptr, label, ranges._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot add mapping to enumeration field class object"
         )
 
@@ -293,7 +302,7 @@ class _UnsignedEnumerationFieldClassConst(
     _get_mapping_labels_for_value = staticmethod(
         native_bt.field_class_enumeration_unsigned_get_mapping_labels_for_value
     )
-    _check_int_type = staticmethod(utils._check_uint64)
+    _check_int_type = staticmethod(bt2_utils._check_uint64)
 
 
 class _UnsignedEnumerationFieldClass(
@@ -320,7 +329,7 @@ class _SignedEnumerationFieldClassConst(
     _get_mapping_labels_for_value = staticmethod(
         native_bt.field_class_enumeration_signed_get_mapping_labels_for_value
     )
-    _check_int_type = staticmethod(utils._check_int64)
+    _check_int_type = staticmethod(bt2_utils._check_int64)
 
 
 class _SignedEnumerationFieldClass(
@@ -394,7 +403,7 @@ class _StructureFieldClassMember(_StructureFieldClassMemberConst):
 
     def _user_attributes(self, user_attributes):
         value = bt2_value.create_value(user_attributes)
-        utils._check_type(value, bt2_value.MapValue)
+        bt2_utils._check_type(value, bt2_value.MapValue)
         native_bt.field_class_structure_member_set_user_attributes(
             self._ptr, value._ptr
         )
@@ -439,7 +448,7 @@ class _StructureFieldClassConst(_FieldClassConst, collections.abc.Mapping):
             yield native_bt.field_class_structure_member_get_name(member_ptr)
 
     def member_at_index(self, index):
-        utils._check_uint64(index)
+        bt2_utils._check_uint64(index)
 
         if index >= len(self):
             raise IndexError
@@ -460,8 +469,8 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass):
     _structure_member_field_class_pycls = property(lambda _: _StructureFieldClassMember)
 
     def append_member(self, name, field_class, user_attributes=None):
-        utils._check_str(name)
-        utils._check_type(field_class, _FieldClass)
+        bt2_utils._check_str(name)
+        bt2_utils._check_type(field_class, _FieldClass)
 
         if name in self:
             raise ValueError("duplicate member name '{}'".format(name))
@@ -470,12 +479,12 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass):
 
         if user_attributes is not None:
             # check now that user attributes are valid
-            user_attributes_value = bt2.create_value(user_attributes)
+            user_attributes_value = bt2_value.create_value(user_attributes)
 
         status = native_bt.field_class_structure_append_member(
             self._ptr, name, field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot append member to structure field class object"
         )
 
@@ -582,7 +591,7 @@ class _OptionWithBoolSelectorFieldClass(
     _NAME = "Option (with boolean selector)"
 
     def _selector_is_reversed(self, selector_is_reversed):
-        utils._check_bool(selector_is_reversed)
+        bt2_utils._check_bool(selector_is_reversed)
         native_bt.field_class_option_with_selector_field_bool_set_selector_is_reversed(
             self._ptr, selector_is_reversed
         )
@@ -665,7 +674,7 @@ class _VariantFieldClassOption(_VariantFieldClassOptionConst):
 
     def _user_attributes(self, user_attributes):
         value = bt2_value.create_value(user_attributes)
-        utils._check_type(value, bt2_value.MapValue)
+        bt2_utils._check_type(value, bt2_value.MapValue)
         native_bt.field_class_variant_option_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
@@ -770,7 +779,7 @@ class _VariantFieldClassConst(_FieldClassConst, collections.abc.Mapping):
             yield native_bt.field_class_variant_option_get_name(base_opt_ptr)
 
     def option_at_index(self, index):
-        utils._check_uint64(index)
+        bt2_utils._check_uint64(index)
 
         if index >= len(self):
             raise IndexError
@@ -801,8 +810,8 @@ class _VariantFieldClassWithoutSelector(
     _NAME = "Variant (without selector)"
 
     def append_option(self, name, field_class, user_attributes=None):
-        utils._check_str(name)
-        utils._check_type(field_class, _FieldClass)
+        bt2_utils._check_str(name)
+        bt2_utils._check_type(field_class, _FieldClass)
 
         if name in self:
             raise ValueError("duplicate option name '{}'".format(name))
@@ -811,12 +820,12 @@ class _VariantFieldClassWithoutSelector(
 
         if user_attributes is not None:
             # check now that user attributes are valid
-            user_attributes_value = bt2.create_value(user_attributes)
+            user_attributes_value = bt2_value.create_value(user_attributes)
 
         status = native_bt.field_class_variant_without_selector_append_option(
             self._ptr, name, field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot append option to variant field class object"
         )
 
@@ -851,9 +860,9 @@ class _VariantFieldClassWithIntegerSelector(
     _NAME = "Variant (with selector)"
 
     def append_option(self, name, field_class, ranges, user_attributes=None):
-        utils._check_str(name)
-        utils._check_type(field_class, _FieldClass)
-        utils._check_type(ranges, self._variant_option_pycls._range_set_pycls)
+        bt2_utils._check_str(name)
+        bt2_utils._check_type(field_class, _FieldClass)
+        bt2_utils._check_type(ranges, self._variant_option_pycls._range_set_pycls)
 
         if name in self:
             raise ValueError("duplicate option name '{}'".format(name))
@@ -865,12 +874,12 @@ class _VariantFieldClassWithIntegerSelector(
 
         if user_attributes is not None:
             # check now that user attributes are valid
-            user_attributes_value = bt2.create_value(user_attributes)
+            user_attributes_value = bt2_value.create_value(user_attributes)
 
         # TODO: check overlaps (precondition of self._append_option())
 
         status = self._append_option(self._ptr, name, field_class._ptr, ranges._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot append option to variant field class object"
         )
 
index a2d39629bf38ac7edc9a97b2e3f01fdfd9be3cc0..d64d22861e4b7524f98a184f834a6f0df21fb9dd 100644 (file)
@@ -3,7 +3,9 @@
 # Copyright (c) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
 
 import collections
-from bt2 import native_bt, object
+
+from bt2 import object as bt2_object
+from bt2 import native_bt
 
 
 class FieldPathScope:
@@ -34,9 +36,14 @@ class _CurrentOptionContentFieldPathItem(_FieldPathItem):
     pass
 
 
-class _FieldPathConst(object._SharedObject, collections.abc.Iterable):
-    _get_ref = staticmethod(native_bt.field_path_get_ref)
-    _put_ref = staticmethod(native_bt.field_path_put_ref)
+class _FieldPathConst(bt2_object._SharedObject, collections.abc.Iterable):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.field_path_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.field_path_put_ref(ptr)
 
     @property
     def root_scope(self):
index ed99ef079c924c1e046770ae33ee0bffd381159b..6bd4e1e7ee69ba8035344941b26420836ca153d8 100644 (file)
@@ -2,14 +2,19 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import interrupter as bt2_interrupter
-from bt2 import connection as bt2_connection
-from bt2 import component as bt2_component
 import functools
+
+from bt2 import mip as bt2_mip
 from bt2 import port as bt2_port
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
+from bt2 import value as bt2_value
+from bt2 import object as bt2_object
 from bt2 import logging as bt2_logging
-import bt2
+from bt2 import component as bt2_component
+from bt2 import native_bt
+from bt2 import connection as bt2_connection
+from bt2 import interrupter as bt2_interrupter
 
 
 def _graph_port_added_listener_from_native(
@@ -22,20 +27,25 @@ def _graph_port_added_listener_from_native(
     user_listener(component, port)
 
 
-class Graph(object._SharedObject):
-    _get_ref = staticmethod(native_bt.graph_get_ref)
-    _put_ref = staticmethod(native_bt.graph_put_ref)
+class Graph(bt2_object._SharedObject):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.graph_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.graph_put_ref(ptr)
 
     def __init__(self, mip_version=0):
-        utils._check_uint64(mip_version)
+        bt2_utils._check_uint64(mip_version)
 
-        if mip_version > bt2.get_maximal_mip_version():
+        if mip_version > bt2_mip.get_maximal_mip_version():
             raise ValueError("unknown MIP version {}".format(mip_version))
 
         ptr = native_bt.graph_create(mip_version)
 
         if ptr is None:
-            raise bt2._MemoryError("cannot create graph object")
+            raise bt2_error._MemoryError("cannot create graph object")
 
         super().__init__(ptr)
 
@@ -82,36 +92,38 @@ class Graph(object._SharedObject):
                 )
             )
 
-        utils._check_str(name)
-        utils._check_log_level(logging_level)
+        bt2_utils._check_str(name)
+        bt2_utils._check_log_level(logging_level)
         base_cc_ptr = component_class._bt_component_class_ptr()
 
         if obj is not None and not native_bt.bt2_is_python_component_class(base_cc_ptr):
             raise ValueError("cannot pass a Python object to a non-Python component")
 
-        if params is not None and not isinstance(params, (dict, bt2.MapValue)):
+        if params is not None and not isinstance(params, (dict, bt2_value.MapValue)):
             raise TypeError("'params' parameter is not a 'dict' or a 'bt2.MapValue'.")
 
-        params = bt2.create_value(params)
+        params = bt2_value.create_value(params)
 
         params_ptr = params._ptr if params is not None else None
 
         status, comp_ptr = add_fn(
             self._ptr, cc_ptr, name, params_ptr, obj, logging_level
         )
-        utils._handle_func_status(status, "cannot add component to graph")
+        bt2_utils._handle_func_status(status, "cannot add component to graph")
         assert comp_ptr
         return bt2_component._create_component_from_const_ptr_and_get_ref(
             comp_ptr, cc_type
         )
 
     def connect_ports(self, upstream_port, downstream_port):
-        utils._check_type(upstream_port, bt2_port._OutputPortConst)
-        utils._check_type(downstream_port, bt2_port._InputPortConst)
+        bt2_utils._check_type(upstream_port, bt2_port._OutputPortConst)
+        bt2_utils._check_type(downstream_port, bt2_port._InputPortConst)
         status, conn_ptr = native_bt.graph_connect_ports(
             self._ptr, upstream_port._ptr, downstream_port._ptr
         )
-        utils._handle_func_status(status, "cannot connect component ports within graph")
+        bt2_utils._handle_func_status(
+            status, "cannot connect component ports within graph"
+        )
         assert conn_ptr
         return bt2_connection._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr)
 
@@ -126,21 +138,21 @@ class Graph(object._SharedObject):
 
         listener_ids = fn(self._ptr, listener_from_native)
         if listener_ids is None:
-            raise bt2._Error("cannot add listener to graph object")
+            raise bt2_error._Error("cannot add listener to graph object")
 
         # keep the partial's reference
         self._listener_partials.append(listener_from_native)
 
     def run_once(self):
         status = native_bt.graph_run_once(self._ptr)
-        utils._handle_func_status(status, "graph object could not run once")
+        bt2_utils._handle_func_status(status, "graph object could not run once")
 
     def run(self):
         status = native_bt.graph_run(self._ptr)
-        utils._handle_func_status(status, "graph object stopped running")
+        bt2_utils._handle_func_status(status, "graph object stopped running")
 
     def add_interrupter(self, interrupter):
-        utils._check_type(interrupter, bt2_interrupter.Interrupter)
+        bt2_utils._check_type(interrupter, bt2_interrupter.Interrupter)
         native_bt.graph_add_interrupter(self._ptr, interrupter._ptr)
 
     @property
index 79006f33c49cfe3edf0c05b2d056185c6c42453f..86bfd467163d0515a5521861843d0827542a2b19 100644 (file)
@@ -2,9 +2,12 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
 import collections.abc
-import bt2
+
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
+from bt2 import object as bt2_object
+from bt2 import native_bt
 
 
 class _IntegerRangeConst:
@@ -51,8 +54,8 @@ class _IntegerRange(_IntegerRangeConst):
 
 
 class _SignedIntegerRangeConst(_IntegerRangeConst):
-    _is_type = staticmethod(utils._is_int64)
-    _check_type = staticmethod(utils._check_int64)
+    _is_type = staticmethod(bt2_utils._is_int64)
+    _check_type = staticmethod(bt2_utils._check_int64)
 
 
 class SignedIntegerRange(_SignedIntegerRangeConst, _IntegerRange):
@@ -60,15 +63,15 @@ class SignedIntegerRange(_SignedIntegerRangeConst, _IntegerRange):
 
 
 class _UnsignedIntegerRangeConst(_IntegerRangeConst):
-    _is_type = staticmethod(utils._is_uint64)
-    _check_type = staticmethod(utils._check_uint64)
+    _is_type = staticmethod(bt2_utils._is_uint64)
+    _check_type = staticmethod(bt2_utils._check_uint64)
 
 
 class UnsignedIntegerRange(_UnsignedIntegerRangeConst, _IntegerRange):
     pass
 
 
-class _IntegerRangeSetConst(object._SharedObject, collections.abc.Set):
+class _IntegerRangeSetConst(bt2_object._SharedObject, collections.abc.Set):
     def __len__(self):
         range_set_ptr = self._as_range_set_ptr(self._ptr)
         count = native_bt.integer_range_set_get_range_count(range_set_ptr)
@@ -91,7 +94,6 @@ class _IntegerRangeSetConst(object._SharedObject, collections.abc.Set):
             yield self._range_pycls(lower, upper)
 
     def __eq__(self, other):
-
         if not isinstance(other, _IntegerRangeSetConst):
             return False
 
@@ -110,7 +112,7 @@ class _IntegerRangeSet(_IntegerRangeSetConst, collections.abc.MutableSet):
         ptr = self._create_range_set()
 
         if ptr is None:
-            raise bt2._MemoryError("cannot create range set object")
+            raise bt2_error._MemoryError("cannot create range set object")
 
         super().__init__(ptr)
 
@@ -128,15 +130,21 @@ class _IntegerRangeSet(_IntegerRangeSetConst, collections.abc.MutableSet):
                 rg = self._range_pycls(rg[0], rg[1])
 
         status = self._add_range(self._ptr, rg.lower, rg.upper)
-        utils._handle_func_status(status, "cannot add range to range set object")
+        bt2_utils._handle_func_status(status, "cannot add range to range set object")
 
     def discard(self, rg):
         raise NotImplementedError
 
 
 class _SignedIntegerRangeSetConst(_IntegerRangeSetConst):
-    _get_ref = staticmethod(native_bt.integer_range_set_signed_get_ref)
-    _put_ref = staticmethod(native_bt.integer_range_set_signed_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.integer_range_set_signed_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.integer_range_set_signed_put_ref(ptr)
+
     _as_range_set_ptr = staticmethod(
         native_bt.integer_range_set_signed_as_range_set_const
     )
@@ -156,8 +164,14 @@ class SignedIntegerRangeSet(_SignedIntegerRangeSetConst, _IntegerRangeSet):
 
 
 class _UnsignedIntegerRangeSetConst(_IntegerRangeSetConst):
-    _get_ref = staticmethod(native_bt.integer_range_set_unsigned_get_ref)
-    _put_ref = staticmethod(native_bt.integer_range_set_unsigned_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.integer_range_set_unsigned_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.integer_range_set_unsigned_put_ref(ptr)
+
     _as_range_set_ptr = staticmethod(
         native_bt.integer_range_set_unsigned_as_range_set_const
     )
index 39c22883d2d0304abfdc49b161e8af6efe2d142a..cd7ef806903f7a6658a441b76f8b23ece2ac421d 100644 (file)
@@ -2,19 +2,25 @@
 #
 # Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object
-import bt2
+from bt2 import error as bt2_error
+from bt2 import object as bt2_object
+from bt2 import native_bt
 
 
-class Interrupter(object._SharedObject):
-    _get_ref = staticmethod(native_bt.interrupter_get_ref)
-    _put_ref = staticmethod(native_bt.interrupter_put_ref)
+class Interrupter(bt2_object._SharedObject):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.interrupter_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.interrupter_put_ref(ptr)
 
     def __init__(self):
         ptr = native_bt.interrupter_create()
 
         if ptr is None:
-            raise bt2._MemoryError("cannot create interrupter object")
+            raise bt2_error._MemoryError("cannot create interrupter object")
 
         super().__init__(ptr)
 
index 5039d923b59208c1b057f78256ec85083f99e96e..c56f696190c3c7cb1ed2bf59ccb87b3fd9df9115 100644 (file)
@@ -2,11 +2,13 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import clock_snapshot as bt2_clock_snapshot
+from bt2 import event as bt2_event
+from bt2 import utils as bt2_utils
+from bt2 import object as bt2_object
 from bt2 import packet as bt2_packet
 from bt2 import stream as bt2_stream
-from bt2 import event as bt2_event
+from bt2 import native_bt
+from bt2 import clock_snapshot as bt2_clock_snapshot
 
 
 def _create_from_ptr(ptr):
@@ -14,9 +16,14 @@ def _create_from_ptr(ptr):
     return _MESSAGE_TYPE_TO_CLS[msg_type]._create_from_ptr(ptr)
 
 
-class _MessageConst(object._SharedObject):
-    _get_ref = staticmethod(native_bt.message_get_ref)
-    _put_ref = staticmethod(native_bt.message_put_ref)
+class _MessageConst(bt2_object._SharedObject):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.message_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.message_put_ref(ptr)
 
     @staticmethod
     def _check_has_default_clock_class(clock_class):
@@ -134,7 +141,7 @@ class _StreamMessageConst(_MessageConst, _MessageWithDefaultClockSnapshot):
 
 class _StreamMessage(_StreamMessageConst, _Message):
     def _default_clock_snapshot(self, raw_value):
-        utils._check_uint64(raw_value)
+        bt2_utils._check_uint64(raw_value)
         self._set_default_clock_snapshot(self._ptr, raw_value)
 
     _default_clock_snapshot = property(
@@ -232,7 +239,7 @@ class _DiscardedMessage(_DiscardedMessageConst, _Message):
     _stream_pycls = property(lambda _: bt2_stream._Stream)
 
     def _set_count(self, count):
-        utils._check_uint64(count)
+        bt2_utils._check_uint64(count)
 
         if count == 0:
             raise ValueError("discarded {} count is 0".format(self._item_name))
index e2efa732baba9729f2635456341d11121717b009..b6887dc0d20e9f5139a9cd363d9815e9850f7b8e 100644 (file)
@@ -2,15 +2,18 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import message as bt2_message
 import collections.abc
-from bt2 import stream as bt2_stream
-from bt2 import event_class as bt2_event_class
-from bt2 import packet as bt2_packet
+
 from bt2 import port as bt2_port
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
+from bt2 import object as bt2_object
+from bt2 import packet as bt2_packet
+from bt2 import stream as bt2_stream
+from bt2 import message as bt2_message
+from bt2 import native_bt
 from bt2 import clock_class as bt2_clock_class
-import bt2
+from bt2 import event_class as bt2_event_class
 
 
 class _MessageIterator(collections.abc.Iterator):
@@ -18,9 +21,16 @@ class _MessageIterator(collections.abc.Iterator):
         raise NotImplementedError
 
 
-class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageIterator):
-    _get_ref = staticmethod(native_bt.message_iterator_get_ref)
-    _put_ref = staticmethod(native_bt.message_iterator_put_ref)
+class _UserComponentInputPortMessageIterator(
+    bt2_object._SharedObject, _MessageIterator
+):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.message_iterator_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.message_iterator_put_ref(ptr)
 
     def __init__(self, ptr):
         self._current_msgs = []
@@ -32,7 +42,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera
             status, msgs = native_bt.bt2_self_component_port_input_get_msg_range(
                 self._ptr
             )
-            utils._handle_func_status(
+            bt2_utils._handle_func_status(
                 status, "unexpected error: cannot advance the message iterator"
             )
             self._current_msgs = msgs
@@ -45,7 +55,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera
 
     def can_seek_beginning(self):
         (status, res) = native_bt.message_iterator_can_seek_beginning(self._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status,
             "cannot check whether or not message iterator can seek its beginning",
         )
@@ -57,21 +67,21 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera
         self._at = 0
 
         status = native_bt.message_iterator_seek_beginning(self._ptr)
-        utils._handle_func_status(status, "cannot seek message iterator beginning")
+        bt2_utils._handle_func_status(status, "cannot seek message iterator beginning")
 
     def can_seek_ns_from_origin(self, ns_from_origin):
-        utils._check_int64(ns_from_origin)
+        bt2_utils._check_int64(ns_from_origin)
         (status, res) = native_bt.message_iterator_can_seek_ns_from_origin(
             self._ptr, ns_from_origin
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status,
             "cannot check whether or not message iterator can seek given ns from origin",
         )
         return res != 0
 
     def seek_ns_from_origin(self, ns_from_origin):
-        utils._check_int64(ns_from_origin)
+        bt2_utils._check_int64(ns_from_origin)
 
         # Forget about buffered messages, they won't be valid after seeking.
         self._current_msgs.clear()
@@ -80,7 +90,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera
         status = native_bt.message_iterator_seek_ns_from_origin(
             self._ptr, ns_from_origin
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "message iterator cannot seek given ns from origin"
         )
 
@@ -94,7 +104,7 @@ class _MessageIteratorConfiguration:
         self._ptr = ptr
 
     def can_seek_forward(self, value):
-        utils._check_bool(value)
+        bt2_utils._check_bool(value)
         native_bt.self_message_iterator_configuration_set_can_seek_forward(
             self._ptr, value
         )
@@ -158,18 +168,18 @@ class _UserMessageIterator(_MessageIterator):
         pass
 
     def __next__(self):
-        raise bt2.Stop
+        raise bt2_utils.Stop
 
     def _bt_next_from_native(self):
         # this can raise anything: it's catched by the native part
         try:
             msg = next(self)
         except StopIteration:
-            raise bt2.Stop
+            raise bt2_utils.Stop
         except Exception:
             raise
 
-        utils._check_type(msg, bt2_message._MessageConst)
+        bt2_utils._check_type(msg, bt2_message._MessageConst)
 
         # The reference we return will be given to the message array.
         # However, the `msg` Python object may stay alive, if the user has kept
@@ -186,7 +196,7 @@ class _UserMessageIterator(_MessageIterator):
         #   method indicates whether the iterator can seek beginning.
         if hasattr(self, "_user_can_seek_beginning"):
             can_seek_beginning = self._user_can_seek_beginning()
-            utils._check_bool(can_seek_beginning)
+            bt2_utils._check_bool(can_seek_beginning)
             return can_seek_beginning
         else:
             return hasattr(self, "_user_seek_beginning")
@@ -206,7 +216,7 @@ class _UserMessageIterator(_MessageIterator):
 
         if hasattr(self, "_user_can_seek_ns_from_origin"):
             can_seek_ns_from_origin = self._user_can_seek_ns_from_origin(ns_from_origin)
-            utils._check_bool(can_seek_ns_from_origin)
+            bt2_utils._check_bool(can_seek_ns_from_origin)
             return can_seek_ns_from_origin
         else:
             return hasattr(self, "_user_seek_ns_from_origin")
@@ -215,7 +225,7 @@ class _UserMessageIterator(_MessageIterator):
         self._user_seek_ns_from_origin(ns_from_origin)
 
     def _create_message_iterator(self, input_port):
-        utils._check_type(input_port, bt2_port._UserComponentInputPort)
+        bt2_utils._check_type(input_port, bt2_port._UserComponentInputPort)
 
         if not input_port.is_connected:
             raise ValueError("input port is not connected")
@@ -226,18 +236,18 @@ class _UserMessageIterator(_MessageIterator):
         ) = native_bt.bt2_message_iterator_create_from_message_iterator(
             self._bt_ptr, input_port._ptr
         )
-        utils._handle_func_status(status, "cannot create message iterator object")
+        bt2_utils._handle_func_status(status, "cannot create message iterator object")
         assert msg_iter_ptr is not None
 
         return _UserComponentInputPortMessageIterator(msg_iter_ptr)
 
     def _create_event_message(self, event_class, parent, default_clock_snapshot=None):
-        utils._check_type(event_class, bt2_event_class._EventClass)
+        bt2_utils._check_type(event_class, bt2_event_class._EventClass)
 
         if event_class.stream_class.supports_packets:
-            utils._check_type(parent, bt2_packet._Packet)
+            bt2_utils._check_type(parent, bt2_packet._Packet)
         else:
-            utils._check_type(parent, bt2_stream._Stream)
+            bt2_utils._check_type(parent, bt2_stream._Stream)
 
         if default_clock_snapshot is not None:
             if event_class.stream_class.default_clock_class is None:
@@ -245,7 +255,7 @@ class _UserMessageIterator(_MessageIterator):
                     "event messages in this stream must not have a default clock snapshot"
                 )
 
-            utils._check_uint64(default_clock_snapshot)
+            bt2_utils._check_uint64(default_clock_snapshot)
 
             if event_class.stream_class.supports_packets:
                 ptr = native_bt.message_event_create_with_packet_and_default_clock_snapshot(
@@ -271,27 +281,29 @@ class _UserMessageIterator(_MessageIterator):
                 )
 
         if ptr is None:
-            raise bt2._MemoryError("cannot create event message object")
+            raise bt2_error._MemoryError("cannot create event message object")
 
         return bt2_message._EventMessage(ptr)
 
     def _create_message_iterator_inactivity_message(self, clock_class, clock_snapshot):
-        utils._check_type(clock_class, bt2_clock_class._ClockClass)
+        bt2_utils._check_type(clock_class, bt2_clock_class._ClockClass)
         ptr = native_bt.message_message_iterator_inactivity_create(
             self._bt_ptr, clock_class._ptr, clock_snapshot
         )
 
         if ptr is None:
-            raise bt2._MemoryError("cannot create inactivity message object")
+            raise bt2_error._MemoryError("cannot create inactivity message object")
 
         return bt2_message._MessageIteratorInactivityMessage(ptr)
 
     def _create_stream_beginning_message(self, stream, default_clock_snapshot=None):
-        utils._check_type(stream, bt2_stream._Stream)
+        bt2_utils._check_type(stream, bt2_stream._Stream)
 
         ptr = native_bt.message_stream_beginning_create(self._bt_ptr, stream._ptr)
         if ptr is None:
-            raise bt2._MemoryError("cannot create stream beginning message object")
+            raise bt2_error._MemoryError(
+                "cannot create stream beginning message object"
+            )
 
         msg = bt2_message._StreamBeginningMessage(ptr)
 
@@ -301,11 +313,11 @@ class _UserMessageIterator(_MessageIterator):
         return msg
 
     def _create_stream_end_message(self, stream, default_clock_snapshot=None):
-        utils._check_type(stream, bt2_stream._Stream)
+        bt2_utils._check_type(stream, bt2_stream._Stream)
 
         ptr = native_bt.message_stream_end_create(self._bt_ptr, stream._ptr)
         if ptr is None:
-            raise bt2._MemoryError("cannot create stream end message object")
+            raise bt2_error._MemoryError("cannot create stream end message object")
 
         msg = bt2_message._StreamEndMessage(ptr)
 
@@ -315,7 +327,7 @@ class _UserMessageIterator(_MessageIterator):
         return msg
 
     def _create_packet_beginning_message(self, packet, default_clock_snapshot=None):
-        utils._check_type(packet, bt2_packet._Packet)
+        bt2_utils._check_type(packet, bt2_packet._Packet)
 
         if packet.stream.cls.packets_have_beginning_default_clock_snapshot:
             if default_clock_snapshot is None:
@@ -323,7 +335,7 @@ class _UserMessageIterator(_MessageIterator):
                     "packet beginning messages in this stream must have a default clock snapshot"
                 )
 
-            utils._check_uint64(default_clock_snapshot)
+            bt2_utils._check_uint64(default_clock_snapshot)
             ptr = native_bt.message_packet_beginning_create_with_default_clock_snapshot(
                 self._bt_ptr, packet._ptr, default_clock_snapshot
             )
@@ -336,12 +348,14 @@ class _UserMessageIterator(_MessageIterator):
             ptr = native_bt.message_packet_beginning_create(self._bt_ptr, packet._ptr)
 
         if ptr is None:
-            raise bt2._MemoryError("cannot create packet beginning message object")
+            raise bt2_error._MemoryError(
+                "cannot create packet beginning message object"
+            )
 
         return bt2_message._PacketBeginningMessage(ptr)
 
     def _create_packet_end_message(self, packet, default_clock_snapshot=None):
-        utils._check_type(packet, bt2_packet._Packet)
+        bt2_utils._check_type(packet, bt2_packet._Packet)
 
         if packet.stream.cls.packets_have_end_default_clock_snapshot:
             if default_clock_snapshot is None:
@@ -349,7 +363,7 @@ class _UserMessageIterator(_MessageIterator):
                     "packet end messages in this stream must have a default clock snapshot"
                 )
 
-            utils._check_uint64(default_clock_snapshot)
+            bt2_utils._check_uint64(default_clock_snapshot)
             ptr = native_bt.message_packet_end_create_with_default_clock_snapshot(
                 self._bt_ptr, packet._ptr, default_clock_snapshot
             )
@@ -362,14 +376,14 @@ class _UserMessageIterator(_MessageIterator):
             ptr = native_bt.message_packet_end_create(self._bt_ptr, packet._ptr)
 
         if ptr is None:
-            raise bt2._MemoryError("cannot create packet end message object")
+            raise bt2_error._MemoryError("cannot create packet end message object")
 
         return bt2_message._PacketEndMessage(ptr)
 
     def _create_discarded_events_message(
         self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None
     ):
-        utils._check_type(stream, bt2_stream._Stream)
+        bt2_utils._check_type(stream, bt2_stream._Stream)
 
         if not stream.cls.supports_discarded_events:
             raise ValueError("stream class does not support discarded events")
@@ -380,8 +394,8 @@ class _UserMessageIterator(_MessageIterator):
                     "discarded events have default clock snapshots for this stream class"
                 )
 
-            utils._check_uint64(beg_clock_snapshot)
-            utils._check_uint64(end_clock_snapshot)
+            bt2_utils._check_uint64(beg_clock_snapshot)
+            bt2_utils._check_uint64(end_clock_snapshot)
 
             if beg_clock_snapshot > end_clock_snapshot:
                 raise ValueError(
@@ -404,7 +418,7 @@ class _UserMessageIterator(_MessageIterator):
             ptr = native_bt.message_discarded_events_create(self._bt_ptr, stream._ptr)
 
         if ptr is None:
-            raise bt2._MemoryError("cannot discarded events message object")
+            raise bt2_error._MemoryError("cannot discarded events message object")
 
         msg = bt2_message._DiscardedEventsMessage(ptr)
 
@@ -416,7 +430,7 @@ class _UserMessageIterator(_MessageIterator):
     def _create_discarded_packets_message(
         self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None
     ):
-        utils._check_type(stream, bt2_stream._Stream)
+        bt2_utils._check_type(stream, bt2_stream._Stream)
 
         if not stream.cls.supports_discarded_packets:
             raise ValueError("stream class does not support discarded packets")
@@ -427,8 +441,8 @@ class _UserMessageIterator(_MessageIterator):
                     "discarded packets have default clock snapshots for this stream class"
                 )
 
-            utils._check_uint64(beg_clock_snapshot)
-            utils._check_uint64(end_clock_snapshot)
+            bt2_utils._check_uint64(beg_clock_snapshot)
+            bt2_utils._check_uint64(end_clock_snapshot)
 
             if beg_clock_snapshot > end_clock_snapshot:
                 raise ValueError(
@@ -451,7 +465,7 @@ class _UserMessageIterator(_MessageIterator):
             ptr = native_bt.message_discarded_packets_create(self._bt_ptr, stream._ptr)
 
         if ptr is None:
-            raise bt2._MemoryError("cannot discarded packets message object")
+            raise bt2_error._MemoryError("cannot discarded packets message object")
 
         msg = bt2_message._DiscardedPacketsMessage(ptr)
 
index 552c7b2aad5c0724e469fc4abbaab7429df9af12..21cb0c61b700719ad113e717c7b6c490ed0b36ea 100644 (file)
@@ -2,25 +2,28 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, utils
-import bt2
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
+from bt2 import logging as bt2_logging
+from bt2 import native_bt
+from bt2 import component_descriptor as bt2_component_descriptor
 
 
 def get_greatest_operative_mip_version(
-    component_descriptors, log_level=bt2.LoggingLevel.NONE
+    component_descriptors, log_level=bt2_logging.LoggingLevel.NONE
 ):
-    utils._check_log_level(log_level)
+    bt2_utils._check_log_level(log_level)
     comp_descr_set_ptr = native_bt.component_descriptor_set_create()
 
     if comp_descr_set_ptr is None:
-        raise bt2._MemoryError("cannot create component descriptor set object")
+        raise bt2_error._MemoryError("cannot create component descriptor set object")
 
     if len(component_descriptors) == 0:
         raise ValueError("no component descriptors")
 
     try:
         for descr in component_descriptors:
-            if type(descr) is not bt2.ComponentDescriptor:
+            if type(descr) is not bt2_component_descriptor.ComponentDescriptor:
                 raise TypeError("'{}' is not a component descriptor".format(descr))
 
             base_cc_ptr = descr.component_class._bt_component_class_ptr()
@@ -32,7 +35,7 @@ def get_greatest_operative_mip_version(
             status = native_bt.bt2_component_descriptor_set_add_descriptor_with_initialize_method_data(
                 comp_descr_set_ptr, base_cc_ptr, params_ptr, descr.obj
             )
-            utils._handle_func_status(
+            bt2_utils._handle_func_status(
                 status, "cannot add descriptor to component descriptor set"
             )
 
@@ -43,7 +46,9 @@ def get_greatest_operative_mip_version(
         if status == native_bt.__BT_FUNC_STATUS_NO_MATCH:
             return None
 
-        utils._handle_func_status(status, "cannot get greatest operative MIP version")
+        bt2_utils._handle_func_status(
+            status, "cannot get greatest operative MIP version"
+        )
         return version
     finally:
         native_bt.component_descriptor_set_put_ref(comp_descr_set_ptr)
index fed138eced74e526699c074f53903df915d049a4..dcff667f49aaf52d1a889d29e06e8cfdcb187156 100644 (file)
@@ -3,6 +3,9 @@
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
 
+import abc
+
+
 class _BaseObject:
     # Ensure that the object always has _ptr set, even if it throws during
     # construction.
@@ -42,7 +45,6 @@ class _BaseObject:
 
 
 class _UniqueObject(_BaseObject):
-
     # Create a _UniqueObject.
     #
     #   - ptr: SWIG Object, pointer to the unique object.
@@ -69,14 +71,14 @@ class _UniqueObject(_BaseObject):
 
 
 # Python object that owns a reference to a Babeltrace object.
-class _SharedObject(_BaseObject):
-
+class _SharedObject(_BaseObject, abc.ABC):
     # Get a new reference on ptr.
     #
     # This must be implemented by subclasses to work correctly with a pointer
     # of the native type they wrap.
 
     @staticmethod
+    @abc.abstractmethod
     def _get_ref(ptr):
         raise NotImplementedError
 
@@ -86,6 +88,7 @@ class _SharedObject(_BaseObject):
     # of the native type they wrap.
 
     @staticmethod
+    @abc.abstractmethod
     def _put_ref(ptr):
         raise NotImplementedError
 
index 9325a7d6fc29cbb0168c9651761d72f1fa2d0642..0e7605f1660d253de5a4b5423c465154f3adfcbe 100644 (file)
@@ -2,8 +2,9 @@
 #
 # Copyright (c) 2016-2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object
 from bt2 import field as bt2_field
+from bt2 import object as bt2_object
+from bt2 import native_bt
 
 
 def _bt2_stream():
@@ -12,9 +13,15 @@ def _bt2_stream():
     return bt2_stream
 
 
-class _PacketConst(object._SharedObject):
-    _get_ref = staticmethod(native_bt.packet_get_ref)
-    _put_ref = staticmethod(native_bt.packet_put_ref)
+class _PacketConst(bt2_object._SharedObject):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.packet_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.packet_put_ref(ptr)
+
     _borrow_stream_ptr = staticmethod(native_bt.packet_borrow_stream_const)
     _borrow_context_field_ptr = staticmethod(
         native_bt.packet_borrow_context_field_const
index 6888cb12f33b1352d56b567f941e9800b352c59f..0c9906679125773f3d449e9ff4396d60c041be84 100644 (file)
@@ -2,16 +2,19 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+import os.path
 import collections.abc
+
+from bt2 import utils as bt2_utils
+from bt2 import object as bt2_object
 from bt2 import component as bt2_component
-import os.path
+from bt2 import native_bt
 
 
 def find_plugins_in_path(path, recurse=True, fail_on_load_error=False):
-    utils._check_str(path)
-    utils._check_bool(recurse)
-    utils._check_bool(fail_on_load_error)
+    bt2_utils._check_str(path)
+    bt2_utils._check_bool(recurse)
+    bt2_utils._check_bool(fail_on_load_error)
     plugin_set_ptr = None
 
     if os.path.isfile(path):
@@ -28,7 +31,7 @@ def find_plugins_in_path(path, recurse=True, fail_on_load_error=False):
     if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND:
         return
 
-    utils._handle_func_status(status, "failed to find plugins")
+    bt2_utils._handle_func_status(status, "failed to find plugins")
     assert plugin_set_ptr is not None
     return _PluginSet._create_from_ptr(plugin_set_ptr)
 
@@ -40,11 +43,11 @@ def find_plugins(
     find_in_static=True,
     fail_on_load_error=False,
 ):
-    utils._check_bool(find_in_std_env_var)
-    utils._check_bool(find_in_user_dir)
-    utils._check_bool(find_in_sys_dir)
-    utils._check_bool(find_in_static)
-    utils._check_bool(fail_on_load_error)
+    bt2_utils._check_bool(find_in_std_env_var)
+    bt2_utils._check_bool(find_in_user_dir)
+    bt2_utils._check_bool(find_in_sys_dir)
+    bt2_utils._check_bool(find_in_static)
+    bt2_utils._check_bool(fail_on_load_error)
     plugin_set_ptr = None
 
     status, plugin_set_ptr = native_bt.bt2_plugin_find_all(
@@ -58,7 +61,7 @@ def find_plugins(
     if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND:
         return
 
-    utils._handle_func_status(status, "failed to find plugins")
+    bt2_utils._handle_func_status(status, "failed to find plugins")
     assert plugin_set_ptr is not None
     return _PluginSet._create_from_ptr(plugin_set_ptr)
 
@@ -71,8 +74,8 @@ def find_plugin(
     find_in_static=True,
     fail_on_load_error=False,
 ):
-    utils._check_str(name)
-    utils._check_bool(fail_on_load_error)
+    bt2_utils._check_str(name)
+    bt2_utils._check_bool(fail_on_load_error)
     status, ptr = native_bt.bt2_plugin_find(
         name,
         int(find_in_std_env_var),
@@ -85,14 +88,19 @@ def find_plugin(
     if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND:
         return
 
-    utils._handle_func_status(status, "failed to find plugin")
+    bt2_utils._handle_func_status(status, "failed to find plugin")
     assert ptr is not None
     return _Plugin._create_from_ptr(ptr)
 
 
-class _PluginSet(object._SharedObject, collections.abc.Sequence):
-    _put_ref = staticmethod(native_bt.plugin_set_put_ref)
-    _get_ref = staticmethod(native_bt.plugin_set_get_ref)
+class _PluginSet(bt2_object._SharedObject, collections.abc.Sequence):
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.plugin_set_put_ref(ptr)
+
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.plugin_set_get_ref(ptr)
 
     def __len__(self):
         count = native_bt.plugin_set_get_plugin_count(self._ptr)
@@ -100,7 +108,7 @@ class _PluginSet(object._SharedObject, collections.abc.Sequence):
         return count
 
     def __getitem__(self, index):
-        utils._check_uint64(index)
+        bt2_utils._check_uint64(index)
 
         if index >= len(self):
             raise IndexError
@@ -175,7 +183,7 @@ class _PluginComponentClasses(collections.abc.Mapping):
         self._plugin = plugin
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
         cc_ptr = self._borrow_component_class_by_name(self._plugin._ptr, key)
 
         if cc_ptr is None:
@@ -231,9 +239,14 @@ class _PluginSinkComponentClasses(_PluginComponentClasses):
     _comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_SINK
 
 
-class _Plugin(object._SharedObject):
-    _put_ref = staticmethod(native_bt.plugin_put_ref)
-    _get_ref = staticmethod(native_bt.plugin_get_ref)
+class _Plugin(bt2_object._SharedObject):
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.plugin_put_ref(ptr)
+
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.plugin_get_ref(ptr)
 
     @property
     def name(self):
index 0d6484782b7f710698189c4d1d23e5083b1e0650..b9a5529af81abc110bd62f186dd1e9fa726c1bef 100644 (file)
@@ -2,7 +2,8 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object
+from bt2 import object as bt2_object
+from bt2 import native_bt
 
 
 def _bt2_connection():
@@ -29,7 +30,7 @@ def _create_self_from_ptr_and_get_ref(ptr, port_type):
     return cls._create_from_ptr_and_get_ref(ptr)
 
 
-class _PortConst(object._SharedObject):
+class _PortConst(bt2_object._SharedObject):
     @classmethod
     def _get_ref(cls, ptr):
         ptr = cls._as_port_ptr(ptr)
index 6f067e8b4d59c4e794362372a05ccf8f008393ec..5702a2fe38f20f7a94c23d5e295002f15deaa83d 100644 (file)
@@ -2,10 +2,10 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import utils
-from bt2 import component as bt2_component
 import sys
 
+from bt2 import utils as bt2_utils
+from bt2 import component as bt2_component
 
 # Python plugin path to `_PluginInfo` (cache)
 _plugin_infos = {}
@@ -27,16 +27,16 @@ def register_plugin(
             "cannot find module '{}' in loaded modules".format(module_name)
         )
 
-    utils._check_str(name)
+    bt2_utils._check_str(name)
 
     if description is not None:
-        utils._check_str(description)
+        bt2_utils._check_str(description)
 
     if author is not None:
-        utils._check_str(author)
+        bt2_utils._check_str(author)
 
     if license is not None:
-        utils._check_str(license)
+        bt2_utils._check_str(license)
 
     if version is not None:
         if not _validate_version(version):
@@ -91,9 +91,9 @@ def _try_load_plugin_module(path):
         # do not load module and create plugin info twice for this path
         return _plugin_infos[path]
 
-    import importlib.machinery
-    import inspect
     import hashlib
+    import inspect
+    import importlib.machinery
 
     if path is None:
         raise TypeError("missing path")
index 354404a6e3ee199d7fe7aff4c52eff621d476b76..de6f4441c9089372e73af63a34e0dbd03b1551c2 100644 (file)
@@ -2,10 +2,12 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import interrupter as bt2_interrupter
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
 from bt2 import value as bt2_value
-import bt2
+from bt2 import object as bt2_object
+from bt2 import native_bt
+from bt2 import interrupter as bt2_interrupter
 
 
 def _bt2_component():
@@ -29,9 +31,14 @@ class _QueryExecutorCommon:
         return native_bt.query_executor_get_logging_level(self._common_ptr)
 
 
-class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
-    _get_ref = staticmethod(native_bt.query_executor_get_ref)
-    _put_ref = staticmethod(native_bt.query_executor_put_ref)
+class QueryExecutor(bt2_object._SharedObject, _QueryExecutorCommon):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.query_executor_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.query_executor_put_ref(ptr)
 
     def _as_query_executor_ptr(self):
         return self._ptr
@@ -50,12 +57,12 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
                 o = component_class
                 raise TypeError("'{}' is not a component class object".format(o))
 
-        utils._check_str(object_name)
+        bt2_utils._check_str(object_name)
 
         if params is None:
             params_ptr = native_bt.value_null
         else:
-            params = bt2.create_value(params)
+            params = bt2_value.create_value(params)
             params_ptr = params._ptr
 
         cc_ptr = component_class._bt_component_class_ptr()
@@ -73,7 +80,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
         )
 
         if ptr is None:
-            raise bt2._MemoryError("cannot create query executor object")
+            raise bt2_error._MemoryError("cannot create query executor object")
 
         super().__init__(ptr)
 
@@ -83,7 +90,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
         self._method_obj = method_obj
 
     def add_interrupter(self, interrupter):
-        utils._check_type(interrupter, bt2_interrupter.Interrupter)
+        bt2_utils._check_type(interrupter, bt2_interrupter.Interrupter)
         native_bt.query_executor_add_interrupter(self._ptr, interrupter._ptr)
 
     @property
@@ -92,9 +99,11 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
         return bt2_interrupter.Interrupter._create_from_ptr_and_get_ref(ptr)
 
     def _set_logging_level(self, log_level):
-        utils._check_log_level(log_level)
+        bt2_utils._check_log_level(log_level)
         status = native_bt.query_executor_set_logging_level(self._ptr, log_level)
-        utils._handle_func_status(status, "cannot set query executor's logging level")
+        bt2_utils._handle_func_status(
+            status, "cannot set query executor's logging level"
+        )
 
     logging_level = property(
         fget=_QueryExecutorCommon.logging_level, fset=_set_logging_level
@@ -107,7 +116,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon):
 
     def query(self):
         status, result_ptr = native_bt.query_executor_query(self._ptr)
-        utils._handle_func_status(status, "cannot query component class")
+        bt2_utils._handle_func_status(status, "cannot query component class")
         assert result_ptr is not None
         return bt2_value._create_from_const_ptr(result_ptr)
 
index f1329623c2633c780c5bc06f2035c70ef6f6c0cf..9d8d1ae9a816138a974c84c5c85a48f4219b743b 100644 (file)
@@ -2,12 +2,13 @@
 #
 # Copyright (c) 2016-2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, utils
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
+from bt2 import value as bt2_value
 from bt2 import object as bt2_object
 from bt2 import packet as bt2_packet
+from bt2 import native_bt
 from bt2 import stream_class as bt2_stream_class
-from bt2 import value as bt2_value
-import bt2
 
 
 def _bt2_trace():
@@ -17,8 +18,14 @@ def _bt2_trace():
 
 
 class _StreamConst(bt2_object._SharedObject):
-    _get_ref = staticmethod(native_bt.stream_get_ref)
-    _put_ref = staticmethod(native_bt.stream_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.stream_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.stream_put_ref(ptr)
+
     _borrow_class_ptr = staticmethod(native_bt.stream_borrow_class_const)
     _borrow_user_attributes_ptr = staticmethod(
         native_bt.stream_borrow_user_attributes_const
@@ -77,13 +84,13 @@ class _Stream(_StreamConst):
         packet_ptr = native_bt.packet_create(self._ptr)
 
         if packet_ptr is None:
-            raise bt2._MemoryError("cannot create packet object")
+            raise bt2_error._MemoryError("cannot create packet object")
 
         return bt2_packet._Packet._create_from_ptr(packet_ptr)
 
     def _user_attributes(self, user_attributes):
         value = bt2_value.create_value(user_attributes)
-        utils._check_type(value, bt2_value.MapValue)
+        bt2_utils._check_type(value, bt2_value.MapValue)
         native_bt.stream_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(
@@ -91,7 +98,7 @@ class _Stream(_StreamConst):
     )
 
     def _name(self, name):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
         native_bt.stream_set_name(self._ptr, name)
 
     _name = property(fget=_StreamConst.name.fget, fset=_name)
index 885ba746dae01ae37b9db9ae5a0873453fe58804..5c6faa07fd6c25c3bd1352ffcb94e9534646200f 100644 (file)
@@ -2,13 +2,16 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
-from bt2 import field_class as bt2_field_class
-from bt2 import event_class as bt2_event_class
-from bt2 import clock_class as bt2_clock_class
-from bt2 import value as bt2_value
 import collections.abc
 
+from bt2 import utils as bt2_utils
+from bt2 import value as bt2_value
+from bt2 import object as bt2_object
+from bt2 import native_bt
+from bt2 import clock_class as bt2_clock_class
+from bt2 import event_class as bt2_event_class
+from bt2 import field_class as bt2_field_class
+
 
 def _bt2_trace_class():
     from bt2 import trace_class as bt2_trace_class
@@ -16,9 +19,15 @@ def _bt2_trace_class():
     return bt2_trace_class
 
 
-class _StreamClassConst(object._SharedObject, collections.abc.Mapping):
-    _get_ref = staticmethod(native_bt.stream_class_get_ref)
-    _put_ref = staticmethod(native_bt.stream_class_put_ref)
+class _StreamClassConst(bt2_object._SharedObject, collections.abc.Mapping):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.stream_class_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.stream_class_put_ref(ptr)
+
     _borrow_event_class_ptr_by_id = staticmethod(
         native_bt.stream_class_borrow_event_class_by_id_const
     )
@@ -46,7 +55,7 @@ class _StreamClassConst(object._SharedObject, collections.abc.Mapping):
     _clock_class_cls = property(lambda _: bt2_clock_class._ClockClassConst)
 
     def __getitem__(self, key):
-        utils._check_int64(key)
+        bt2_utils._check_int64(key)
         ec_ptr = self._borrow_event_class_ptr_by_id(self._ptr, key)
 
         if ec_ptr is None:
@@ -165,8 +174,14 @@ class _StreamClassConst(object._SharedObject, collections.abc.Mapping):
 
 
 class _StreamClass(_StreamClassConst):
-    _get_ref = staticmethod(native_bt.stream_class_get_ref)
-    _put_ref = staticmethod(native_bt.stream_class_put_ref)
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.stream_class_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.stream_class_put_ref(ptr)
+
     _borrow_event_class_ptr_by_id = staticmethod(
         native_bt.stream_class_borrow_event_class_by_id
     )
@@ -224,7 +239,7 @@ class _StreamClass(_StreamClassConst):
                     "id not provided, but stream class does not assign automatic event class ids"
                 )
 
-            utils._check_uint64(id)
+            bt2_utils._check_uint64(id)
             ec_ptr = native_bt.event_class_create_with_id(self._ptr, id)
 
         event_class = bt2_event_class._EventClass._create_from_ptr(ec_ptr)
@@ -257,7 +272,7 @@ class _StreamClass(_StreamClassConst):
 
     def _name(self, name):
         status = native_bt.stream_class_set_name(self._ptr, name)
-        utils._handle_func_status(status, "cannot set stream class object's name")
+        bt2_utils._handle_func_status(status, "cannot set stream class object's name")
 
     _name = property(fset=_name)
 
@@ -294,7 +309,7 @@ class _StreamClass(_StreamClassConst):
         status = native_bt.stream_class_set_packet_context_field_class(
             self._ptr, packet_context_field_class._ptr
         )
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot set stream class' packet context field class"
         )
 
@@ -303,7 +318,7 @@ class _StreamClass(_StreamClassConst):
     def _event_common_context_field_class(self, event_common_context_field_class):
         set_context_fn = native_bt.stream_class_set_event_common_context_field_class
         status = set_context_fn(self._ptr, event_common_context_field_class._ptr)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot set stream class' event context field type"
         )
 
@@ -334,12 +349,12 @@ class _StreamClass(_StreamClassConst):
     ):
         # Name
         if name is not None:
-            utils._check_str(name)
+            bt2_utils._check_str(name)
 
         # User attributes
         if user_attributes is not None:
             value = bt2_value.create_value(user_attributes)
-            utils._check_type(value, bt2_value.MapValue)
+            bt2_utils._check_type(value, bt2_value.MapValue)
 
         # Packet context field class
         if packet_context_field_class is not None:
@@ -348,30 +363,30 @@ class _StreamClass(_StreamClassConst):
                     "cannot have a packet context field class without supporting packets"
                 )
 
-            utils._check_type(
+            bt2_utils._check_type(
                 packet_context_field_class, bt2_field_class._StructureFieldClass
             )
 
         # Event common context field class
         if event_common_context_field_class is not None:
-            utils._check_type(
+            bt2_utils._check_type(
                 event_common_context_field_class, bt2_field_class._StructureFieldClass
             )
 
         # Default clock class
         if default_clock_class is not None:
-            utils._check_type(default_clock_class, bt2_clock_class._ClockClass)
+            bt2_utils._check_type(default_clock_class, bt2_clock_class._ClockClass)
 
         # Assigns automatic event class id
-        utils._check_bool(assigns_automatic_event_class_id)
+        bt2_utils._check_bool(assigns_automatic_event_class_id)
 
         # Assigns automatic stream id
-        utils._check_bool(assigns_automatic_stream_id)
+        bt2_utils._check_bool(assigns_automatic_stream_id)
 
         # Packets
-        utils._check_bool(supports_packets)
-        utils._check_bool(packets_have_beginning_default_clock_snapshot)
-        utils._check_bool(packets_have_end_default_clock_snapshot)
+        bt2_utils._check_bool(supports_packets)
+        bt2_utils._check_bool(packets_have_beginning_default_clock_snapshot)
+        bt2_utils._check_bool(packets_have_end_default_clock_snapshot)
 
         if not supports_packets:
             if packets_have_beginning_default_clock_snapshot:
@@ -384,8 +399,8 @@ class _StreamClass(_StreamClassConst):
                 )
 
         # Discarded events
-        utils._check_bool(supports_discarded_events)
-        utils._check_bool(discarded_events_have_default_clock_snapshots)
+        bt2_utils._check_bool(supports_discarded_events)
+        bt2_utils._check_bool(discarded_events_have_default_clock_snapshots)
 
         if discarded_events_have_default_clock_snapshots:
             if not supports_discarded_events:
@@ -399,8 +414,8 @@ class _StreamClass(_StreamClassConst):
                 )
 
         # Discarded packets
-        utils._check_bool(supports_discarded_packets)
-        utils._check_bool(discarded_packets_have_default_clock_snapshots)
+        bt2_utils._check_bool(supports_discarded_packets)
+        bt2_utils._check_bool(discarded_packets_have_default_clock_snapshots)
 
         if supports_discarded_packets and not supports_packets:
             raise ValueError(
index 1c56b034c400789beade4d3aff1f1fa55bcb2678..a7038b2880757ec0f713f36eac8196be853a14bf 100644 (file)
@@ -2,14 +2,17 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import native_bt, object, utils
+import uuid as uuidp
+import functools
 import collections.abc
+
+from bt2 import error as bt2_error
+from bt2 import utils as bt2_utils
 from bt2 import value as bt2_value
+from bt2 import object as bt2_object
 from bt2 import stream as bt2_stream
+from bt2 import native_bt
 from bt2 import stream_class as bt2_stream_class
-import bt2
-import functools
-import uuid as uuidp
 
 
 def _bt2_trace_class():
@@ -27,7 +30,7 @@ class _TraceEnvironmentConst(collections.abc.Mapping):
         self._trace = trace
 
     def __getitem__(self, key):
-        utils._check_str(key)
+        bt2_utils._check_str(key)
 
         borrow_entry_fn = native_bt.trace_borrow_environment_entry_value_by_name_const
         value_ptr = borrow_entry_fn(self._trace._ptr, key)
@@ -66,15 +69,23 @@ class _TraceEnvironment(_TraceEnvironmentConst, collections.abc.MutableMapping):
             raise TypeError("expected str or int, got {}".format(type(value)))
 
         status = set_env_entry_fn(self._trace._ptr, key, value)
-        utils._handle_func_status(status, "cannot set trace object's environment entry")
+        bt2_utils._handle_func_status(
+            status, "cannot set trace object's environment entry"
+        )
 
     def __delitem__(self, key):
         raise NotImplementedError
 
 
-class _TraceConst(object._SharedObject, collections.abc.Mapping):
-    _get_ref = staticmethod(native_bt.trace_get_ref)
-    _put_ref = staticmethod(native_bt.trace_put_ref)
+class _TraceConst(bt2_object._SharedObject, collections.abc.Mapping):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.trace_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.trace_put_ref(ptr)
+
     _borrow_stream_ptr_by_id = staticmethod(native_bt.trace_borrow_stream_by_id_const)
     _borrow_stream_ptr_by_index = staticmethod(
         native_bt.trace_borrow_stream_by_index_const
@@ -96,7 +107,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         return count
 
     def __getitem__(self, id):
-        utils._check_uint64(id)
+        bt2_utils._check_uint64(id)
 
         stream_ptr = self._borrow_stream_ptr_by_id(self._ptr, id)
 
@@ -148,7 +159,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         if not callable(listener):
             raise TypeError("'listener' parameter is not callable")
 
-        handle = utils._ListenerHandle(self.addr)
+        handle = bt2_utils._ListenerHandle(self.addr)
 
         fn = native_bt.bt2_trace_add_destruction_listener
         listener_from_native = functools.partial(
@@ -156,7 +167,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         )
 
         status, listener_id = fn(self._ptr, listener_from_native)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot add destruction listener to trace object"
         )
 
@@ -165,7 +176,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         return handle
 
     def remove_destruction_listener(self, listener_handle):
-        utils._check_type(listener_handle, utils._ListenerHandle)
+        bt2_utils._check_type(listener_handle, bt2_utils._ListenerHandle)
 
         if listener_handle._addr != self.addr:
             raise ValueError(
@@ -178,7 +189,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping):
         status = native_bt.trace_remove_destruction_listener(
             self._ptr, listener_handle._listener_id
         )
-        utils._handle_func_status(status)
+        bt2_utils._handle_func_status(status)
         listener_handle._invalidate()
 
 
@@ -195,27 +206,27 @@ class _Trace(_TraceConst):
     _trace_env_pycls = property(lambda _: _TraceEnvironment)
 
     def _name(self, name):
-        utils._check_str(name)
+        bt2_utils._check_str(name)
         status = native_bt.trace_set_name(self._ptr, name)
-        utils._handle_func_status(status, "cannot set trace class object's name")
+        bt2_utils._handle_func_status(status, "cannot set trace class object's name")
 
     _name = property(fset=_name)
 
     def _user_attributes(self, user_attributes):
         value = bt2_value.create_value(user_attributes)
-        utils._check_type(value, bt2_value.MapValue)
+        bt2_utils._check_type(value, bt2_value.MapValue)
         native_bt.trace_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
 
     def _uuid(self, uuid):
-        utils._check_type(uuid, uuidp.UUID)
+        bt2_utils._check_type(uuid, uuidp.UUID)
         native_bt.trace_set_uuid(self._ptr, uuid.bytes)
 
     _uuid = property(fset=_uuid)
 
     def create_stream(self, stream_class, id=None, name=None, user_attributes=None):
-        utils._check_type(stream_class, bt2_stream_class._StreamClass)
+        bt2_utils._check_type(stream_class, bt2_stream_class._StreamClass)
 
         if stream_class.assigns_automatic_stream_id:
             if id is not None:
@@ -230,13 +241,13 @@ class _Trace(_TraceConst):
                     "id not provided, but stream class does not assign automatic stream ids"
                 )
 
-            utils._check_uint64(id)
+            bt2_utils._check_uint64(id)
             stream_ptr = native_bt.stream_create_with_id(
                 stream_class._ptr, self._ptr, id
             )
 
         if stream_ptr is None:
-            raise bt2._MemoryError("cannot create stream object")
+            raise bt2_error._MemoryError("cannot create stream object")
 
         stream = bt2_stream._Stream._create_from_ptr(stream_ptr)
 
index f66f385527934d5348e8e83ed9aa3730396db293..418639405a0fed653c62241ebe2bbb6c969447d2 100644 (file)
@@ -4,15 +4,18 @@
 # Copyright (c) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
 # Copyright (c) 2019 Simon Marchi <simon.marchi@efficios.com>
 
-from bt2 import native_bt, utils, object
-from bt2 import stream_class as bt2_stream_class
-from bt2 import field_class as bt2_field_class
-from bt2 import integer_range_set as bt2_integer_range_set
+import functools
+import collections.abc
+
+from bt2 import error as bt2_error
 from bt2 import trace as bt2_trace
+from bt2 import utils as bt2_utils
 from bt2 import value as bt2_value
-import collections.abc
-import functools
-import bt2
+from bt2 import object as bt2_object
+from bt2 import native_bt
+from bt2 import field_class as bt2_field_class
+from bt2 import stream_class as bt2_stream_class
+from bt2 import integer_range_set as bt2_integer_range_set
 
 
 def _trace_class_destruction_listener_from_native(
@@ -23,9 +26,15 @@ def _trace_class_destruction_listener_from_native(
     handle._invalidate()
 
 
-class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
-    _get_ref = staticmethod(native_bt.trace_class_get_ref)
-    _put_ref = staticmethod(native_bt.trace_class_put_ref)
+class _TraceClassConst(bt2_object._SharedObject, collections.abc.Mapping):
+    @staticmethod
+    def _get_ref(ptr):
+        native_bt.trace_class_get_ref(ptr)
+
+    @staticmethod
+    def _put_ref(ptr):
+        native_bt.trace_class_put_ref(ptr)
+
     _borrow_stream_class_ptr_by_index = staticmethod(
         native_bt.trace_class_borrow_stream_class_by_index_const
     )
@@ -56,7 +65,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
     # Get a stream class by stream id.
 
     def __getitem__(self, key):
-        utils._check_uint64(key)
+        bt2_utils._check_uint64(key)
 
         sc_ptr = self._borrow_stream_class_ptr_by_id(self._ptr, key)
         if sc_ptr is None:
@@ -81,11 +90,10 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
     # Add a listener to be called when the trace class is destroyed.
 
     def add_destruction_listener(self, listener):
-
         if not callable(listener):
             raise TypeError("'listener' parameter is not callable")
 
-        handle = utils._ListenerHandle(self.addr)
+        handle = bt2_utils._ListenerHandle(self.addr)
 
         listener_from_native = functools.partial(
             _trace_class_destruction_listener_from_native, listener, handle
@@ -93,7 +101,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
 
         fn = native_bt.bt2_trace_class_add_destruction_listener
         status, listener_id = fn(self._ptr, listener_from_native)
-        utils._handle_func_status(
+        bt2_utils._handle_func_status(
             status, "cannot add destruction listener to trace class object"
         )
 
@@ -102,7 +110,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
         return handle
 
     def remove_destruction_listener(self, listener_handle):
-        utils._check_type(listener_handle, utils._ListenerHandle)
+        bt2_utils._check_type(listener_handle, bt2_utils._ListenerHandle)
 
         if listener_handle._addr != self.addr:
             raise ValueError(
@@ -117,7 +125,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping):
         status = native_bt.trace_class_remove_destruction_listener(
             self._ptr, listener_handle._listener_id
         )
-        utils._handle_func_status(status)
+        bt2_utils._handle_func_status(status)
         listener_handle._invalidate()
 
 
@@ -142,7 +150,7 @@ class _TraceClass(_TraceClassConst):
         trace_ptr = native_bt.trace_create(self._ptr)
 
         if trace_ptr is None:
-            raise bt2._MemoryError("cannot create trace class object")
+            raise bt2_error._MemoryError("cannot create trace class object")
 
         trace = bt2_trace._Trace._create_from_ptr(trace_ptr)
 
@@ -210,7 +218,7 @@ class _TraceClass(_TraceClassConst):
                     "id not provided, but trace class does not assign automatic stream class ids"
                 )
 
-            utils._check_uint64(id)
+            bt2_utils._check_uint64(id)
             sc_ptr = native_bt.stream_class_create_with_id(self._ptr, id)
 
         sc = bt2_stream_class._StreamClass._create_from_ptr(sc_ptr)
@@ -255,13 +263,13 @@ class _TraceClass(_TraceClassConst):
 
     def _user_attributes(self, user_attributes):
         value = bt2_value.create_value(user_attributes)
-        utils._check_type(value, bt2_value.MapValue)
+        bt2_utils._check_type(value, bt2_value.MapValue)
         native_bt.trace_class_set_user_attributes(self._ptr, value._ptr)
 
     _user_attributes = property(fset=_user_attributes)
 
     def _assigns_automatic_stream_class_id(self, auto_id):
-        utils._check_bool(auto_id)
+        bt2_utils._check_bool(auto_id)
         return native_bt.trace_class_set_assigns_automatic_stream_class_id(
             self._ptr, auto_id
         )
@@ -274,7 +282,9 @@ class _TraceClass(_TraceClassConst):
 
     def _check_field_class_create_status(self, ptr, type_name):
         if ptr is None:
-            raise bt2._MemoryError("cannot create {} field class".format(type_name))
+            raise bt2_error._MemoryError(
+                "cannot create {} field class".format(type_name)
+            )
 
     @staticmethod
     def _set_field_class_user_attrs(fc, user_attributes):
@@ -289,7 +299,7 @@ class _TraceClass(_TraceClassConst):
         return fc
 
     def create_bit_array_field_class(self, length, user_attributes=None):
-        utils._check_uint64(length)
+        bt2_utils._check_uint64(length)
 
         if length < 1 or length > 64:
             raise ValueError(
@@ -414,8 +424,8 @@ class _TraceClass(_TraceClassConst):
         return fc
 
     def create_static_array_field_class(self, elem_fc, length, user_attributes=None):
-        utils._check_type(elem_fc, bt2_field_class._FieldClass)
-        utils._check_uint64(length)
+        bt2_utils._check_type(elem_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_uint64(length)
         ptr = native_bt.field_class_array_static_create(self._ptr, elem_fc._ptr, length)
         self._check_field_class_create_status(ptr, "static array")
         fc = bt2_field_class._StaticArrayFieldClass._create_from_ptr(ptr)
@@ -425,11 +435,11 @@ class _TraceClass(_TraceClassConst):
     def create_dynamic_array_field_class(
         self, elem_fc, length_fc=None, user_attributes=None
     ):
-        utils._check_type(elem_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_type(elem_fc, bt2_field_class._FieldClass)
         length_fc_ptr = None
 
         if length_fc is not None:
-            utils._check_type(length_fc, bt2_field_class._UnsignedIntegerFieldClass)
+            bt2_utils._check_type(length_fc, bt2_field_class._UnsignedIntegerFieldClass)
             length_fc_ptr = length_fc._ptr
 
         ptr = native_bt.field_class_array_dynamic_create(
@@ -443,7 +453,7 @@ class _TraceClass(_TraceClassConst):
     def create_option_without_selector_field_class(
         self, content_fc, user_attributes=None
     ):
-        utils._check_type(content_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_type(content_fc, bt2_field_class._FieldClass)
         ptr = native_bt.field_class_option_without_selector_create(
             self._ptr, content_fc._ptr
         )
@@ -455,9 +465,9 @@ class _TraceClass(_TraceClassConst):
     def create_option_with_bool_selector_field_class(
         self, content_fc, selector_fc, selector_is_reversed=False, user_attributes=None
     ):
-        utils._check_type(content_fc, bt2_field_class._FieldClass)
-        utils._check_bool(selector_is_reversed)
-        utils._check_type(selector_fc, bt2_field_class._BoolFieldClass)
+        bt2_utils._check_type(content_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_bool(selector_is_reversed)
+        bt2_utils._check_type(selector_fc, bt2_field_class._BoolFieldClass)
         ptr = native_bt.field_class_option_with_selector_field_bool_create(
             self._ptr, content_fc._ptr, selector_fc._ptr
         )
@@ -470,19 +480,19 @@ class _TraceClass(_TraceClassConst):
     def create_option_with_integer_selector_field_class(
         self, content_fc, selector_fc, ranges, user_attributes=None
     ):
-        utils._check_type(content_fc, bt2_field_class._FieldClass)
-        utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass)
+        bt2_utils._check_type(content_fc, bt2_field_class._FieldClass)
+        bt2_utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass)
 
         if len(ranges) == 0:
             raise ValueError("integer range set is empty")
 
         if isinstance(selector_fc, bt2_field_class._UnsignedIntegerFieldClass):
-            utils._check_type(ranges, bt2_integer_range_set.UnsignedIntegerRangeSet)
+            bt2_utils._check_type(ranges, bt2_integer_range_set.UnsignedIntegerRangeSet)
             ptr = native_bt.field_class_option_with_selector_field_integer_unsigned_create(
                 self._ptr, content_fc._ptr, selector_fc._ptr, ranges._ptr
             )
         else:
-            utils._check_type(ranges, bt2_integer_range_set.SignedIntegerRangeSet)
+            bt2_utils._check_type(ranges, bt2_integer_range_set.SignedIntegerRangeSet)
             ptr = (
                 native_bt.field_class_option_with_selector_field_integer_signed_create(
                     self._ptr, content_fc._ptr, selector_fc._ptr, ranges._ptr
@@ -498,7 +508,7 @@ class _TraceClass(_TraceClassConst):
         selector_fc_ptr = None
 
         if selector_fc is not None:
-            utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass)
+            bt2_utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass)
             selector_fc_ptr = selector_fc._ptr
 
         ptr = native_bt.field_class_variant_create(self._ptr, selector_fc_ptr)
index ed474cd09c92a04475e1b348f681ef719605badd..3a6b95212137980f6a98b1f0d3cf336a7f87f872 100644 (file)
@@ -2,18 +2,24 @@
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
 
-from bt2 import utils, native_bt
-import bt2
+import numbers
+import datetime
 import itertools
-from bt2 import message_iterator as bt2_message_iterator
+from collections import namedtuple
+
+from bt2 import mip as bt2_mip
 from bt2 import port as bt2_port
-from bt2 import component as bt2_component
+from bt2 import error as bt2_error
+from bt2 import graph as bt2_graph
+from bt2 import utils as bt2_utils
 from bt2 import value as bt2_value
 from bt2 import plugin as bt2_plugin
-import datetime
-from collections import namedtuple
-import numbers
-
+from bt2 import logging as bt2_logging
+from bt2 import component as bt2_component
+from bt2 import native_bt
+from bt2 import query_executor as bt2_query_executor
+from bt2 import message_iterator as bt2_message_iterator
+from bt2 import component_descriptor as bt2_component_descriptor
 
 # a pair of component and ComponentSpec
 _ComponentAndSpec = namedtuple("_ComponentAndSpec", ["comp", "spec"])
@@ -24,9 +30,9 @@ class _BaseComponentSpec:
     # TraceCollectionMessageIterator.
     def __init__(self, params, obj, logging_level):
         if logging_level is not None:
-            utils._check_log_level(logging_level)
+            bt2_utils._check_log_level(logging_level)
 
-        self._params = bt2.create_value(params)
+        self._params = bt2_value.create_value(params)
         self._obj = obj
         self._logging_level = logging_level
 
@@ -50,7 +56,7 @@ class ComponentSpec(_BaseComponentSpec):
         component_class,
         params=None,
         obj=None,
-        logging_level=bt2.LoggingLevel.NONE,
+        logging_level=bt2_logging.LoggingLevel.NONE,
     ):
         if type(params) is str:
             params = {"inputs": [params]}
@@ -59,12 +65,16 @@ class ComponentSpec(_BaseComponentSpec):
 
         is_cc_object = isinstance(
             component_class,
-            (bt2._SourceComponentClassConst, bt2._FilterComponentClassConst),
+            (
+                bt2_component._SourceComponentClassConst,
+                bt2_component._FilterComponentClassConst,
+            ),
         )
         is_user_cc_type = isinstance(
             component_class, bt2_component._UserComponentType
         ) and issubclass(
-            component_class, (bt2._UserSourceComponent, bt2._UserFilterComponent)
+            component_class,
+            (bt2_component._UserSourceComponent, bt2_component._UserFilterComponent),
         )
 
         if not is_cc_object and not is_user_cc_type:
@@ -87,9 +97,9 @@ class ComponentSpec(_BaseComponentSpec):
         component_class_name,
         params=None,
         obj=None,