Add `__repr__` and `__cmp__` methods to command classes.
@@ -20,6 +20,11 @@ class PyinfraCommand(object):
if key in kwargs
}
+ def __eq__(self, other):
+ if isinstance(other, self.__class__) and repr(self) == repr(other):
+ return True
+ return False
+
class StringCommand(PyinfraCommand):
def __init__(self, *bits, **kwargs):
@@ -67,6 +72,9 @@ class FileUploadCommand(PyinfraCommand):
self.src = src
self.dest = dest
+ def __repr__(self):
+ return 'FileUploadCommand({0}, {1})'.format(self.src, self.dest)
+
class FileDownloadCommand(PyinfraCommand):
def __init__(self, src, dest, **kwargs):
@@ -74,6 +82,9 @@ class FileDownloadCommand(PyinfraCommand):
self.src = src
self.dest = dest
+ def __repr__(self):
+ return 'FileDownloadCommand({0}, {1})'.format(self.src, self.dest)
+
class FunctionCommand(PyinfraCommand):
def __init__(self, function, args, func_kwargs, **kwargs):
@@ -81,3 +92,6 @@ class FunctionCommand(PyinfraCommand):
self.function = function
self.args = args
self.kwargs = func_kwargs
+
+ def __repr__(self):
+ return 'FunctionCommand({0})'.format(self.function.__name__)
