# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
+import sys
+
# import all public names
from bt2.clock_class import ClockClassOffset
from bt2.clock_snapshot import _ClockSnapshotConst
from bt2.value import _MapValueConst
from bt2.version import __version__
+if (sys.version_info.major, sys.version_info.minor) != (3, 4):
+
+ def _del_global_name(name):
+ if name in globals():
+ del globals()[name]
-def _del_global_name(name):
- if name in globals():
- del globals()[name]
+ # remove private module names from the package
+ _del_global_name('_native_bt')
+ _del_global_name('clock_class')
+ _del_global_name('clock_snapshot')
+ _del_global_name('component')
+ _del_global_name('connection')
+ _del_global_name('error')
+ _del_global_name('event')
+ _del_global_name('event_class')
+ _del_global_name('field')
+ _del_global_name('field_class')
+ _del_global_name('field_path')
+ _del_global_name('graph')
+ _del_global_name('integer_range_set')
+ _del_global_name('interrupter')
+ _del_global_name('logging')
+ _del_global_name('message')
+ _del_global_name('message_iterator')
+ _del_global_name('native_bt')
+ _del_global_name('object')
+ _del_global_name('packet')
+ _del_global_name('plugin')
+ _del_global_name('port')
+ _del_global_name('py_plugin')
+ _del_global_name('query_executor')
+ _del_global_name('stream')
+ _del_global_name('stream_class')
+ _del_global_name('trace')
+ _del_global_name('trace_class')
+ _del_global_name('trace_collection_message_iterator')
+ _del_global_name('utils')
+ _del_global_name('value')
+ _del_global_name('version')
+ # remove private `_del_global_name` name from the package
+ del _del_global_name
-# remove private module names from the package
-_del_global_name('_native_bt')
-_del_global_name('clock_class')
-_del_global_name('clock_snapshot')
-_del_global_name('component')
-_del_global_name('connection')
-_del_global_name('error')
-_del_global_name('event')
-_del_global_name('event_class')
-_del_global_name('field')
-_del_global_name('field_class')
-_del_global_name('field_path')
-_del_global_name('graph')
-_del_global_name('integer_range_set')
-_del_global_name('interrupter')
-_del_global_name('logging')
-_del_global_name('message')
-_del_global_name('message_iterator')
-_del_global_name('native_bt')
-_del_global_name('object')
-_del_global_name('packet')
-_del_global_name('plugin')
-_del_global_name('port')
-_del_global_name('py_plugin')
-_del_global_name('query_executor')
-_del_global_name('stream')
-_del_global_name('stream_class')
-_del_global_name('trace')
-_del_global_name('trace_class')
-_del_global_name('trace_collection_message_iterator')
-_del_global_name('utils')
-_del_global_name('value')
-_del_global_name('version')
-# remove private `_del_global_name` name from the package
-del _del_global_name
+# remove sys module name from the package
+del sys
class _MemoryError(_Error):
from bt2 import native_bt, object, utils
from bt2 import field_class as bt2_field_class
from bt2 import value as bt2_value
-from bt2 import stream_class as bt2_stream_class
+
+
+def _bt2_stream_class():
+ from bt2 import stream_class as bt2_stream_class
+
+ return bt2_stream_class
class EventClassLogLevel:
_create_value_from_ptr_and_get_ref = staticmethod(
bt2_value._create_from_const_ptr_and_get_ref
)
- _stream_class_pycls = property(lambda s: bt2_stream_class._StreamClassConst)
+ _stream_class_pycls = property(lambda s: _bt2_stream_class()._StreamClassConst)
@property
def stream_class(self):
_create_value_from_ptr_and_get_ref = staticmethod(
bt2_value._create_from_ptr_and_get_ref
)
- _stream_class_pycls = property(lambda s: bt2_stream_class._StreamClass)
+ _stream_class_pycls = property(lambda s: _bt2_stream_class()._StreamClass)
def _user_attributes(self, user_attributes):
value = bt2_value.create_value(user_attributes)
from bt2 import native_bt, object
from bt2 import field as bt2_field
-from bt2 import stream as bt2_stream
+
+
+def _bt2_stream():
+ from bt2 import stream as bt2_stream
+
+ return bt2_stream
class _PacketConst(object._SharedObject):
_borrow_context_field_ptr = staticmethod(
native_bt.packet_borrow_context_field_const
)
- _stream_pycls = property(lambda _: bt2_stream._StreamConst)
+ _stream_pycls = property(lambda _: _bt2_stream()._StreamConst)
_create_field_from_ptr = staticmethod(bt2_field._create_field_from_const_ptr)
@property
class _Packet(_PacketConst):
_borrow_stream_ptr = staticmethod(native_bt.packet_borrow_stream)
_borrow_context_field_ptr = staticmethod(native_bt.packet_borrow_context_field)
- _stream_pycls = property(lambda _: bt2_stream._Stream)
+ _stream_pycls = property(lambda _: _bt2_stream()._Stream)
_create_field_from_ptr = staticmethod(bt2_field._create_field_from_ptr)
# THE SOFTWARE.
from bt2 import native_bt, object
-from bt2 import connection as bt2_connection
+
+
+def _bt2_connection():
+ from bt2 import connection as bt2_connection
+
+ return bt2_connection
def _create_from_const_ptr_and_get_ref(ptr, port_type):
if conn_ptr is None:
return
- return bt2_connection._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr)
+ return _bt2_connection()._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr)
@property
def is_connected(self):
if conn_ptr is None:
return
- return bt2_connection._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr)
+ return _bt2_connection()._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr)
@property
def user_data(self):
from bt2 import native_bt, object, utils
from bt2 import interrupter as bt2_interrupter
-from bt2 import component as bt2_component
from bt2 import value as bt2_value
import bt2
+def _bt2_component():
+ from bt2 import component as bt2_component
+
+ return bt2_component
+
+
class _QueryExecutorCommon:
@property
def _common_ptr(self):
return self._ptr
def __init__(self, component_class, object, params=None, method_obj=None):
- if not isinstance(component_class, bt2_component._ComponentClassConst):
+ if not isinstance(component_class, _bt2_component()._ComponentClassConst):
err = False
try:
- if not issubclass(component_class, bt2_component._UserComponent):
+ if not issubclass(component_class, _bt2_component()._UserComponent):
err = True
except TypeError:
err = True
from bt2 import native_bt, utils
from bt2 import object as bt2_object
from bt2 import packet as bt2_packet
-from bt2 import trace as bt2_trace
from bt2 import stream_class as bt2_stream_class
from bt2 import value as bt2_value
import bt2
+def _bt2_trace():
+ from bt2 import trace as bt2_trace
+
+ return bt2_trace
+
+
class _StreamConst(bt2_object._SharedObject):
_get_ref = staticmethod(native_bt.stream_get_ref)
_put_ref = staticmethod(native_bt.stream_put_ref)
)
_borrow_trace_ptr = staticmethod(native_bt.stream_borrow_trace_const)
_stream_class_pycls = bt2_stream_class._StreamClassConst
- _trace_pycls = bt2_trace._TraceConst
+ _trace_pycls = property(lambda _: _bt2_trace()._TraceConst)
@property
def cls(self):
)
_borrow_trace_ptr = staticmethod(native_bt.stream_borrow_trace)
_stream_class_pycls = bt2_stream_class._StreamClass
- _trace_pycls = bt2_trace._Trace
+ _trace_pycls = property(lambda _: _bt2_trace()._Trace)
def create_packet(self):
if not self.cls.supports_packets:
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 trace_class as bt2_trace_class
from bt2 import clock_class as bt2_clock_class
from bt2 import value as bt2_value
import collections.abc
+def _bt2_trace_class():
+ from bt2 import trace_class as 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)
)
_event_class_cls = property(lambda _: bt2_event_class._EventClassConst)
- _trace_class_cls = property(lambda _: bt2_trace_class._TraceClassConst)
+ _trace_class_cls = property(lambda _: _bt2_trace_class()._TraceClassConst)
_clock_class_cls = property(lambda _: bt2_clock_class._ClockClassConst)
def __getitem__(self, key):
)
_event_class_cls = property(lambda s: bt2_event_class._EventClass)
- _trace_class_cls = property(lambda s: bt2_trace_class._TraceClass)
+ _trace_class_cls = property(lambda s: _bt2_trace_class()._TraceClass)
_clock_class_cls = property(lambda s: bt2_clock_class._ClockClass)
def create_event_class(
import collections.abc
from bt2 import value as bt2_value
from bt2 import stream as bt2_stream
-from bt2 import trace_class as bt2_trace_class
from bt2 import stream_class as bt2_stream_class
import bt2
import functools
import uuid as uuidp
+def _bt2_trace_class():
+ from bt2 import trace_class as bt2_trace_class
+
+ return bt2_trace_class
+
+
class _TraceEnvironmentConst(collections.abc.Mapping):
_create_value_from_ptr_and_get_ref = staticmethod(
bt2_value._create_from_const_ptr_and_get_ref
bt2_value._create_from_const_ptr_and_get_ref
)
_stream_pycls = property(lambda _: bt2_stream._StreamConst)
- _trace_class_pycls = property(lambda _: bt2_trace_class._TraceClassConst)
+ _trace_class_pycls = property(lambda _: _bt2_trace_class()._TraceClassConst)
_trace_env_pycls = property(lambda _: _TraceEnvironmentConst)
def __len__(self):
bt2_value._create_from_ptr_and_get_ref
)
_stream_pycls = property(lambda _: bt2_stream._Stream)
- _trace_class_pycls = property(lambda _: bt2_trace_class._TraceClass)
+ _trace_class_pycls = property(lambda _: _bt2_trace_class()._TraceClass)
_trace_env_pycls = property(lambda _: _TraceEnvironment)
def _name(self, name):