Add type annotations to most of the automagic files.

This commit is contained in:
Mike Auty
2017-12-05 00:23:54 +00:00
parent 4f58f0748f
commit 1f444f7b5e
13 changed files with 153 additions and 57 deletions
+3 -2
View File
@@ -2,7 +2,7 @@
Automagic objects attempt to automatically fill configuration values that a user has not filled.
"""
import typing
from abc import ABCMeta, abstractmethod
from volatility.framework import validity
@@ -46,7 +46,8 @@ class AutomagicInterface(interfaces_configuration.ConfigurableInterface, metacla
def __call__(self, context, config_path, configurable, progress_callback = None):
"""Runs the automagic over the configurable"""
def find_requirements(self, context, config_path, requirement_root, requirement_type, shortcut = True):
def find_requirements(self, context, config_path, requirement_root, requirement_type, shortcut = True) \
-> typing.List[typing.Tuple[str, str, interfaces_configuration.ConstructableRequirementInterface]]:
"""Determines if there is actually an unfulfilled symbol requirement waiting
This ensures we do not carry out an expensive search when there is no requirement for a particular symbol table.
@@ -15,6 +15,7 @@ import logging
import random
import string
import sys
import typing
from abc import ABCMeta, abstractmethod
from volatility.framework import constants
@@ -303,7 +304,7 @@ class RequirementInterface(validity.ValidityRoutines, metaclass = ABCMeta):
class InstanceRequirement(RequirementInterface):
"""Class to represent a single simple type (such as a boolean, a string, an integer or a series of bytes)"""
instance_type = bool
instance_type: typing.Type = bool
def add_requirement(self, requirement):
"""Always raises a TypeError as instance requirements cannot have children"""
@@ -69,6 +69,9 @@ class ContextInterface(object, metaclass = ABCMeta):
Memory constraints may become an issue for this function depending on how much is actually stored in the context"""
return copy.deepcopy(self)
def module(self, module_name, layer_name, offset):
"""Create a module object """
class Module(validity.ValidityRoutines, metaclass = ABCMeta):
"""Maintains state concerning a particular loaded module in memory