python: make all _get_ref/_put_ref proper static methods
[babeltrace.git] / src / bindings / python / bt2 / bt2 / plugin.py
index cb169f484a36ee317ab2cc22011051522f514407..7d3fff91403792f1d93358a36d552eba80666906 100644 (file)
@@ -1,24 +1,6 @@
-# The MIT License (MIT)
+# SPDX-License-Identifier: MIT
 #
 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
 
 from bt2 import native_bt, object, utils
 import collections.abc
@@ -46,7 +28,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')
+    utils._handle_func_status(status, "failed to find plugins")
     assert plugin_set_ptr is not None
     return _PluginSet._create_from_ptr(plugin_set_ptr)
 
@@ -76,7 +58,7 @@ def find_plugins(
     if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND:
         return
 
-    utils._handle_func_status(status, 'failed to find plugins')
+    utils._handle_func_status(status, "failed to find plugins")
     assert plugin_set_ptr is not None
     return _PluginSet._create_from_ptr(plugin_set_ptr)
 
@@ -103,14 +85,19 @@ def find_plugin(
     if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND:
         return
 
-    utils._handle_func_status(status, 'failed to find plugin')
+    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)
+    @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)
@@ -152,12 +139,12 @@ class _PluginVersion:
         return self._extra
 
     def __str__(self):
-        extra = ''
+        extra = ""
 
         if self._extra is not None:
             extra = self._extra
 
-        return '{}.{}.{}{}'.format(self._major, self._minor, self._patch, extra)
+        return "{}.{}.{}{}".format(self._major, self._minor, self._patch, extra)
 
 
 class _PluginComponentClassesIterator(collections.abc.Iterator):
@@ -250,8 +237,13 @@ class _PluginSinkComponentClasses(_PluginComponentClasses):
 
 
 class _Plugin(object._SharedObject):
-    _put_ref = staticmethod(native_bt.plugin_put_ref)
-    _get_ref = staticmethod(native_bt.plugin_get_ref)
+    @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):
This page took 0.026831 seconds and 4 git commands to generate.