From ffcacaec7d42cba3c4d07d21b2e03b1c5ae7c6a3 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Wed, 13 Jan 2016 00:48:54 +0000 Subject: [PATCH] Refactor SchemaNodes into RequirementInterface. --- volatility/framework/configuration/__init__.py | 18 +++++++++--------- .../framework/interfaces/configuration.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/volatility/framework/configuration/__init__.py b/volatility/framework/configuration/__init__.py index 2e5e2ae87..9ec9f8ce6 100644 --- a/volatility/framework/configuration/__init__.py +++ b/volatility/framework/configuration/__init__.py @@ -4,10 +4,10 @@ Created on 7 May 2013 @author: mike """ -from volatility.framework.interfaces.configuration import ConfigurationSchemaNode +from volatility.framework.interfaces.configuration import RequirementInterface -class InstanceRequirement(ConfigurationSchemaNode): +class InstanceRequirement(RequirementInterface): instance_type = bool def validate(self, value, _context): @@ -24,7 +24,7 @@ class StringRequirement(InstanceRequirement): instance_type = str -class TranslationLayerRequirement(ConfigurationSchemaNode): +class TranslationLayerRequirement(RequirementInterface): """Class maintaining the limitations on what sort of address spaces are acceptable""" def __init__(self, name, description = None, default = None, @@ -37,7 +37,7 @@ class TranslationLayerRequirement(ConfigurationSchemaNode): :param layer_name: String detailing the expected name of the required layer, this can be None if it is to be randomly generated :return: """ - ConfigurationSchemaNode.__init__(self, name, description, default, optional) + RequirementInterface.__init__(self, name, description, default, optional) self._constraints = constraints or {} self._layer_name = layer_name @@ -56,11 +56,11 @@ class TranslationLayerRequirement(ConfigurationSchemaNode): raise IndexError((value or "") + " is not a memory layer") -class ChoiceRequirement(ConfigurationSchemaNode): +class ChoiceRequirement(RequirementInterface): """Allows one from a choice of strings""" def __init__(self, choices, *args, **kwargs): - ConfigurationSchemaNode.__init__(self, *args, **kwargs) + RequirementInterface.__init__(self, *args, **kwargs) if not isinstance(choices, list) or any([not isinstance(choice, str) for choice in choices]): raise TypeError("ChoiceRequirement takes a list of strings as choices") self._choices = choices @@ -71,12 +71,12 @@ class ChoiceRequirement(ConfigurationSchemaNode): raise ValueError("Value is not within the set of available choices") -class ListRequirement(ConfigurationSchemaNode): +class ListRequirement(RequirementInterface): def __init__(self, element_type, max_elements, min_elements, *args, **kwargs): - ConfigurationSchemaNode.__init__(self, *args, **kwargs) + RequirementInterface.__init__(self, *args, **kwargs) if isinstance(element_type, ListRequirement): raise TypeError("ListRequirements cannot contain ListRequirements") - self.element_type = self._check_type(element_type, ConfigurationSchemaNode) + self.element_type = self._check_type(element_type, RequirementInterface) self.min_elements = min_elements self.max_elements = max_elements diff --git a/volatility/framework/interfaces/configuration.py b/volatility/framework/interfaces/configuration.py index e520324c8..228bf3580 100644 --- a/volatility/framework/interfaces/configuration.py +++ b/volatility/framework/interfaces/configuration.py @@ -24,7 +24,7 @@ CONFIG_SEPARATOR = "." # Dependency solver # Attempts to fill all dependencies by traversing the various available classes to find a solution -class ConfigurationSchemaNode(validity.ValidityRoutines, metaclass = ABCMeta): +class RequirementInterface(validity.ValidityRoutines, metaclass = ABCMeta): """Class to distinguish configuration elements from everything else""" def __init__(self, name, description = None, default = None, optional = False):