diff --git a/volatility/framework/config.py b/volatility/framework/config.py index 3926b9194..cba237fc4 100644 --- a/volatility/framework/config.py +++ b/volatility/framework/config.py @@ -12,7 +12,7 @@ class Option(validity.ValidityRoutines): def __init__(self, name, option_type, definition = None, description = None): """Creates a new option""" - self.type_check(option_type, type) + self._type_check(option_type, type) self._option_type = option_type self._name = name self._description = description @@ -52,7 +52,7 @@ class ConfigurationGroup(validity.ValidityRoutines): def __setattr__(self, name, value): if name == '_options': setattr(self, name, value) - self.type_check(value, Option) + self._type_check(value, Option) self._options[name] = value raise TypeError("Attribute " + name + " must be an Option object") @@ -72,6 +72,6 @@ class Configuration(validity.ValidityRoutines): def __setattr__(self, attr, value): if attr == '_config_groups': setattr(self, attr, value) - self.type_check(value, ConfigurationGroup) + self._type_check(value, ConfigurationGroup) self._config_groups[attr] = value raise TypeError("Attribute " + attr + " must be a ConfigurationGroup") diff --git a/volatility/framework/interfaces/layers.py b/volatility/framework/interfaces/layers.py index 156522d25..830e5c808 100644 --- a/volatility/framework/interfaces/layers.py +++ b/volatility/framework/interfaces/layers.py @@ -15,8 +15,8 @@ class DataLayerInterface(validity.ValidityRoutines): __metaclass__ = ABCMeta def __init__(self, context, name): - self.type_check(name, str) - self.type_check(context, context_module.ContextInterface) + self._type_check(name, str) + self._type_check(context, context_module.ContextInterface) self._name = name self._context = context diff --git a/volatility/framework/interfaces/objects.py b/volatility/framework/interfaces/objects.py index 2d92c23cb..454d669ac 100644 --- a/volatility/framework/interfaces/objects.py +++ b/volatility/framework/interfaces/objects.py @@ -19,10 +19,10 @@ class ObjectInterface(validity.ValidityRoutines): # Since objects are likely to be instantiated often, # we're only checking that context, offset and parent # Everything else may be wrong, but that will get caught later on - self.type_check(context, context_module.ContextInterface) - self.type_check(offset, int) + self._type_check(context, context_module.ContextInterface) + self._type_check(offset, int) if parent: - self.type_check(parent, ObjectInterface) + self._type_check(parent, ObjectInterface) self._context = context self._parent = None if not parent else parent diff --git a/volatility/framework/interfaces/plugins.py b/volatility/framework/interfaces/plugins.py index 860cdef36..4aa45be6a 100644 --- a/volatility/framework/interfaces/plugins.py +++ b/volatility/framework/interfaces/plugins.py @@ -26,7 +26,7 @@ class PluginInterface(validity.ValidityRoutines): __metaclass__ = ABCMeta def __init__(self, context): - self.type_check(context, context_module.ContextInterface) + self._type_check(context, context_module.ContextInterface) self._context = context @property diff --git a/volatility/framework/interfaces/renderers.py b/volatility/framework/interfaces/renderers.py index b257fda36..e0d783400 100644 --- a/volatility/framework/interfaces/renderers.py +++ b/volatility/framework/interfaces/renderers.py @@ -11,7 +11,7 @@ class Renderer(validity.ValidityRoutines): def __init__(self, options): """Accepts an options object to configure the renderers""" - # FIXME: Once the config option objects are in place, put the type_check in place + # FIXME: Once the config option objects are in place, put the _type_check in place @abstractmethod def get_render_options(self): diff --git a/volatility/framework/interfaces/symbols.py b/volatility/framework/interfaces/symbols.py index f9d1e5edf..346af4f42 100644 --- a/volatility/framework/interfaces/symbols.py +++ b/volatility/framework/interfaces/symbols.py @@ -11,9 +11,9 @@ class SymbolTableInterface(validity.ValidityRoutines): """Handles a table of symbols""" def __init__(self, name, native_structures = None): - self.type_check(native_structures, NativeTableInterface) + self._type_check(native_structures, NativeTableInterface) if name: - self.type_check(name, str) + self._type_check(name, str) self.name = name or None self._native_structures = native_structures diff --git a/volatility/framework/layers/__init__.py b/volatility/framework/layers/__init__.py index fd8a266fb..71aa21e4b 100644 --- a/volatility/framework/layers/__init__.py +++ b/volatility/framework/layers/__init__.py @@ -30,7 +30,7 @@ class Memory(validity.ValidityRoutines): This will throw an exception if the required dependencies are not met """ - self.type_check(layer, interfaces.layers.DataLayerInterface) + self._type_check(layer, interfaces.layers.DataLayerInterface) if isinstance(layer, interfaces.layers.TranslationLayerInterface): if layer.name in self._layers: raise exceptions.LayerException("Layer " + layer.name + " already exists.") diff --git a/volatility/framework/layers/physical.py b/volatility/framework/layers/physical.py index 97489de32..968d5536e 100644 --- a/volatility/framework/layers/physical.py +++ b/volatility/framework/layers/physical.py @@ -14,7 +14,7 @@ class BufferDataLayer(interfaces.layers.DataLayerInterface): def __init__(self, context, name, buffer): interfaces.layers.DataLayerInterface.__init__(self, context, name) - self._buffer = self.type_check(buffer, bytes) + self._buffer = self._type_check(buffer, bytes) @property def maximum_address(self): @@ -36,7 +36,7 @@ class BufferDataLayer(interfaces.layers.DataLayerInterface): def write(self, address, data): """Writes the data from to the buffer""" - self.type_check(data, bytes) + self._type_check(data, bytes) self._buffer = self._buffer[:address] + data + self._buffer[address + len(data):] diff --git a/volatility/framework/objects/templates.py b/volatility/framework/objects/templates.py index 939131236..27c096d50 100644 --- a/volatility/framework/objects/templates.py +++ b/volatility/framework/objects/templates.py @@ -19,7 +19,7 @@ class ObjectTemplate(interfaces.objects.Template, validity.ValidityRoutines): def __init__(self, object_class = None, structure_name = None, **kwargs): interfaces.objects.Template.__init__(self, structure_name = structure_name, **kwargs) - self.class_check(object_class, interfaces.objects.ObjectInterface) + self._class_check(object_class, interfaces.objects.ObjectInterface) self.object_class = object_class @classmethod diff --git a/volatility/framework/renderers/__init__.py b/volatility/framework/renderers/__init__.py index a49a14aa4..b8a2824a9 100644 --- a/volatility/framework/renderers/__init__.py +++ b/volatility/framework/renderers/__init__.py @@ -12,9 +12,9 @@ class TreeRow(validity.ValidityRoutines): """Class providing the interface for an individual Row of the TreeGrid""" def __init__(self, treegrid, values): - self.type_check(treegrid, TreeGrid) + self._type_check(treegrid, TreeGrid) if not isinstance(self, TreeGrid): - self.type_check(values, list) + self._type_check(values, list) treegrid.validate_values(values) self._treegrid = treegrid self._children = [] @@ -22,12 +22,12 @@ class TreeRow(validity.ValidityRoutines): def add_child(self, child): """Appends a child to the current Row""" - self.type_check(child, TreeRow) + self._type_check(child, TreeRow) self._children += [child] def insert_child(self, child, position): """Inserts a child at a specific position in the current Row""" - self.type_check(child, TreeRow) + self._type_check(child, TreeRow) self._children = self._children[:position] + [child] + self._children[:position] def clear(self): @@ -80,7 +80,7 @@ class TreeGrid(TreeRow): :param columns: A list of column tuples made up of (name, type and format_hint). """ - self.type_check(columns, list) + self._type_check(columns, list) converted_columns = [] for (name, column_type, column_format) in columns: is_simple_type = False diff --git a/volatility/framework/renderers/basic.py b/volatility/framework/renderers/basic.py index 3b4e04796..f533d9e95 100644 --- a/volatility/framework/renderers/basic.py +++ b/volatility/framework/renderers/basic.py @@ -18,7 +18,7 @@ class TextRenderer(interface.Renderer): def render(self, grid): """Renders a text grid based on the contents of each element""" - self.type_check(grid, renderers.TreeGrid) + self._type_check(grid, renderers.TreeGrid) # FIXME: Separator should come from options sep = " | " diff --git a/volatility/framework/validity.py b/volatility/framework/validity.py index 219673e70..87c4a7e13 100644 --- a/volatility/framework/validity.py +++ b/volatility/framework/validity.py @@ -8,7 +8,7 @@ Created on 4 May 2013 class ValidityRoutines(object): """Class to hold all validation routines, such as type checking""" - def type_check(self, value, valid_type): + def _type_check(self, value, valid_type): """Checks that value is an instance of valid_type, and returns value if it is, or throws a TypeError otherwise :param value: The value of which to validate the type @@ -20,7 +20,7 @@ class ValidityRoutines(object): valid_type.__name__ + ", not " + type(value).__name__ return value - def class_check(self, klass, valid_class): + def _class_check(self, klass, valid_class): """Checks that class is an instance of valid_class, and returns klass if it is, or throws a TypeError otherwise :param klass: Class to validate @@ -31,7 +31,7 @@ class ValidityRoutines(object): assert issubclass(klass, valid_class), self.__class__.__name__ + " expected " + \ valid_class.__name__ + ", not " + klass.__name__ - def confirm(self, assertion, error): + def _confirm(self, assertion, error): """Acts like an assertion, but will not be disabled when __debug__ is disabled""" if not assertion: if error is None: