python: mark _SharedObject._{get,put}_ref as abstract methods
[babeltrace.git] / src / bindings / python / bt2 / bt2 / object.py
index f73ec04bb67074573de5ee189e7a07f749c4e748..c1a23fdf353c8657503221834884f0ec675075e0 100644 (file)
@@ -1,24 +1,9 @@
-# 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.
+
+
+import abc
 
 
 class _BaseObject:
@@ -38,9 +23,9 @@ class _BaseObject:
         return int(self._ptr)
 
     def __repr__(self):
-        return '<{}.{} object @ {}>'.format(self.__class__.__module__,
-                                            self.__class__.__name__,
-                                            hex(self.addr))
+        return "<{}.{} object @ {}>".format(
+            self.__class__.__module__, self.__class__.__name__, hex(self.addr)
+        )
 
     def __copy__(self):
         raise NotImplementedError
@@ -58,6 +43,7 @@ class _BaseObject:
 # of unique objects, we make it so acquiring a reference on a unique object
 # acquires a reference on its owner.
 
+
 class _UniqueObject(_BaseObject):
 
     # Create a _UniqueObject.
@@ -69,8 +55,7 @@ class _UniqueObject(_BaseObject):
     #   - owner_put_ref: Callback to put a reference on the owner.
 
     @classmethod
-    def _create_from_ptr_and_get_ref(cls, ptr, owner_ptr,
-                                     owner_get_ref, owner_put_ref):
+    def _create_from_ptr_and_get_ref(cls, ptr, owner_ptr, owner_get_ref, owner_put_ref):
         obj = cls.__new__(cls)
 
         obj._ptr = ptr
@@ -87,14 +72,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
 
@@ -104,6 +89,7 @@ class _SharedObject(_BaseObject):
     # of the native type they wrap.
 
     @staticmethod
+    @abc.abstractmethod
     def _put_ref(ptr):
         raise NotImplementedError
 
This page took 0.027422 seconds and 4 git commands to generate.