Make the atom class an abstract class
To enforce the already existing behavior that atoms have execute and revert methods (this is already the de-facto behavior with its subclasses) we might as well have the atom class be abstract and have methods execute() and revert() that need to be implemented in subclasses (which they already are). Change-Id: Idfc25a7c2b01f674a065e3f467607eba4ab89a26
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import abc
|
||||||
|
|
||||||
from oslo_utils import reflection
|
from oslo_utils import reflection
|
||||||
import six
|
import six
|
||||||
|
|
||||||
@@ -128,6 +130,7 @@ def _build_arg_mapping(atom_name, reqs, rebind_args, function, do_infer,
|
|||||||
return required, optional
|
return required, optional
|
||||||
|
|
||||||
|
|
||||||
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class Atom(object):
|
class Atom(object):
|
||||||
"""An abstract flow atom that causes a flow to progress (in some manner).
|
"""An abstract flow atom that causes a flow to progress (in some manner).
|
||||||
|
|
||||||
@@ -205,6 +208,14 @@ class Atom(object):
|
|||||||
"by this atom"
|
"by this atom"
|
||||||
% dict(item=self.name, oo=sorted(out_of_order)))
|
% dict(item=self.name, oo=sorted(out_of_order)))
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def execute(self, *args, **kwargs):
|
||||||
|
"""Executes this atom."""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def revert(self, *args, **kwargs):
|
||||||
|
"""Reverts this atom (undoing any :meth:`execute` side-effects)."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""A non-unique name for this atom (human readable)."""
|
"""A non-unique name for this atom (human readable)."""
|
||||||
|
|||||||
Reference in New Issue
Block a user