For the different base classes, ensure we are using the 'abc' module + appropriate annotations + metaclasses.
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import abc
|
||||||
|
|
||||||
from cloudinit import importer
|
from cloudinit import importer
|
||||||
from cloudinit import log as logging
|
from cloudinit import log as logging
|
||||||
from cloudinit import user_data as ud
|
from cloudinit import user_data as ud
|
||||||
@@ -37,6 +39,9 @@ class DataSourceNotFoundException(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class DataSource(object):
|
class DataSource(object):
|
||||||
|
|
||||||
|
__metaclass__ = abc.ABCMeta
|
||||||
|
|
||||||
def __init__(self, sys_cfg, distro, paths):
|
def __init__(self, sys_cfg, distro, paths):
|
||||||
self.sys_cfg = sys_cfg
|
self.sys_cfg = sys_cfg
|
||||||
self.distro = distro
|
self.distro = distro
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import abc
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import email
|
import email
|
||||||
@@ -233,6 +233,9 @@ class UserDataProcessor(object):
|
|||||||
|
|
||||||
|
|
||||||
class PartHandler(object):
|
class PartHandler(object):
|
||||||
|
|
||||||
|
__metaclass__ = abc.ABCMeta
|
||||||
|
|
||||||
def __init__(self, frequency, version=2):
|
def __init__(self, frequency, version=2):
|
||||||
self.handler_version = version
|
self.handler_version = version
|
||||||
self.frequency = frequency
|
self.frequency = frequency
|
||||||
@@ -240,12 +243,14 @@ class PartHandler(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "%s: [%s]" % (util.obj_name(self), self.list_types())
|
return "%s: [%s]" % (util.obj_name(self), self.list_types())
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
def list_types(self):
|
def list_types(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def handle_part(self, data, ctype, filename, payload, frequency):
|
def handle_part(self, data, ctype, filename, payload, frequency):
|
||||||
return self._handle_part(data, ctype, filename, payload, frequency)
|
return self._handle_part(data, ctype, filename, payload, frequency)
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
def _handle_part(self, data, ctype, filename, payload, frequency):
|
def _handle_part(self, data, ctype, filename, payload, frequency):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user