~lttng/babeltrace/trunk

« back to all changes in this revision

Viewing changes to src/bindings/python/bt2/bt2/utils.py

  • Committer: Philippe Proulx
  • Author(s): Simon Marchi
  • Date: 2023-09-21 17:29:44 UTC
  • Revision ID: git-v1:c345b07873b0cb0ed344bde32a322a1b1edf60ae
python: remove internal `import bt2` imports

Standardize the internal imports to import specific modules like this:

    from bt2 import foo as bt2_foo

... instead of importing the complete bt2 package.

Change-Id: I32eb223a8bcfe841020a2aafb976f121dadd8680
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10388
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#
3
3
# Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
4
4
 
5
 
import bt2
 
5
 
6
6
from bt2 import logging as bt2_logging
7
7
from bt2 import native_bt
8
8
from bt2 import error as bt2_error
141
141
 
142
142
    if status == native_bt.__BT_FUNC_STATUS_ERROR:
143
143
        assert msg is not None
144
 
        raise bt2._Error(msg)
 
144
        raise bt2_error._Error(msg)
145
145
    elif status == native_bt.__BT_FUNC_STATUS_MEMORY_ERROR:
146
146
        assert msg is not None
147
 
        raise bt2._MemoryError(msg)
 
147
        raise bt2_error._MemoryError(msg)
148
148
    elif status == native_bt.__BT_FUNC_STATUS_END:
149
149
        if msg is None:
150
 
            raise bt2.Stop
 
150
            raise Stop
151
151
        else:
152
 
            raise bt2.Stop(msg)
 
152
            raise Stop(msg)
153
153
    elif status == native_bt.__BT_FUNC_STATUS_AGAIN:
154
154
        if msg is None:
155
 
            raise bt2.TryAgain
 
155
            raise TryAgain
156
156
        else:
157
 
            raise bt2.TryAgain(msg)
 
157
            raise TryAgain(msg)
158
158
    elif status == native_bt.__BT_FUNC_STATUS_OVERFLOW_ERROR:
159
159
        if msg is None:
160
 
            raise bt2._OverflowError
 
160
            raise _OverflowError
161
161
        else:
162
 
            raise bt2._OverflowError(msg)
 
162
            raise _OverflowError(msg)
163
163
    elif status == native_bt.__BT_FUNC_STATUS_UNKNOWN_OBJECT:
164
164
        if msg is None:
165
 
            raise bt2.UnknownObject
 
165
            raise UnknownObject
166
166
        else:
167
 
            raise bt2.UnknownObject(msg)
 
167
            raise UnknownObject(msg)
168
168
    else:
169
169
        assert False
170
170