Convert to using ABCMeta to get abstract class failures immediately rather than on method use.

This commit is contained in:
Mike Auty
2014-04-14 02:21:13 +01:00
parent c5156c25cb
commit 3da8bdf28a
5 changed files with 38 additions and 21 deletions
+9 -5
View File
@@ -3,24 +3,27 @@ Created on 6 May 2013
@author: mike
"""
from abc import ABCMeta, abstractmethod, abstractproperty
class ContextInterface(object):
"""All context-like objects must adhere to the following interface."""
"""All context-like objects must adhere to the following interface.
This interface is present to avoid import dependency cycles.
"""
__metaclass__ = ABCMeta
def __init__(self):
"""Initializes the context with a symbol_space"""
### Symbol Space Functions
@property
@abstractproperty
def symbol_space(self):
"""Returns the symbol_space for the context"""
raise NotImplementedError("Symbol_space has not been implemented.")
### Memory Functions
@property
@abstractproperty
def memory(self):
"""Returns the memory object for the context"""
raise NotImplementedError("Memory has not been implemented.")
@@ -31,6 +34,7 @@ class ContextInterface(object):
### Object Factory Functions
@abstractmethod
def object(self, symbol, layer_name, offset):
"""Object factory, takes a context, symbol, offset and optional layer_name