mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-28 12:34:53 +02:00
Rename functions in validity to avoid future member name collisions.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.")
|
||||
|
||||
@@ -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):]
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = " | "
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user