mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-17 20:35:40 +02:00
Slotting has little effect, so don't change so much
This commit is contained in:
@@ -8,7 +8,7 @@ import collections
|
||||
import collections.abc
|
||||
import contextlib
|
||||
import logging
|
||||
from typing import Any, List, Mapping, Optional
|
||||
from typing import Any, Dict, List, Mapping, Optional
|
||||
|
||||
from volatility3.framework import constants, interfaces
|
||||
|
||||
@@ -23,8 +23,6 @@ class ReadOnlyMapping(collections.abc.Mapping):
|
||||
modified, making an immutable mapping.
|
||||
"""
|
||||
|
||||
__slots__ = ("_dict",)
|
||||
|
||||
def __init__(self, dictionary: Mapping[str, Any]) -> None:
|
||||
self._dict = dictionary
|
||||
|
||||
@@ -54,7 +52,7 @@ class ReadOnlyMapping(collections.abc.Mapping):
|
||||
return dict(self) == dict(other)
|
||||
|
||||
|
||||
class ObjectInformation(collections.abc.Mapping):
|
||||
class ObjectInformation(ReadOnlyMapping):
|
||||
"""Contains common information useful/pertinent only to an individual
|
||||
object (like an instance)
|
||||
|
||||
@@ -65,15 +63,6 @@ class ObjectInformation(collections.abc.Mapping):
|
||||
in a single place. These values are based on the :class:`ReadOnlyMapping` class, to prevent their modification.
|
||||
"""
|
||||
|
||||
__slots__ = (
|
||||
"layer_name",
|
||||
"offset",
|
||||
"member_name",
|
||||
"parent",
|
||||
"native_layer_name",
|
||||
"size",
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
layer_name: str,
|
||||
@@ -93,36 +82,17 @@ class ObjectInformation(collections.abc.Mapping):
|
||||
native_layer_name: If this object references other objects (such as a pointer), what layer those objects live in
|
||||
size: The size that the whole structure consumes in bytes
|
||||
"""
|
||||
self.layer_name = layer_name
|
||||
self.offset = offset
|
||||
self.member_name = member_name
|
||||
self.parent = parent
|
||||
self.native_layer_name = native_layer_name or layer_name
|
||||
self.size = size
|
||||
|
||||
def __getattr__(self, attr: str) -> Any:
|
||||
"""Returns the item as an attribute."""
|
||||
if attr in self.__slots__:
|
||||
return getattr(self, attr)
|
||||
raise AttributeError(
|
||||
f"Object has no attribute: {self.__class__.__name__}.{attr}"
|
||||
super().__init__(
|
||||
{
|
||||
"layer_name": layer_name,
|
||||
"offset": offset,
|
||||
"member_name": member_name,
|
||||
"parent": parent,
|
||||
"native_layer_name": native_layer_name or layer_name,
|
||||
"size": size,
|
||||
}
|
||||
)
|
||||
|
||||
def __getitem__(self, name: str) -> Any:
|
||||
"""Returns the item requested."""
|
||||
return getattr(self, name)
|
||||
|
||||
def __iter__(self):
|
||||
"""Returns an iterator of the dictionary items."""
|
||||
return self.__slots__.__iter__()
|
||||
|
||||
def __len__(self) -> int:
|
||||
"""Returns the length of the internal dictionary."""
|
||||
return len(self.__slots__)
|
||||
|
||||
def __eq__(self, other):
|
||||
return dict(self) == dict(other)
|
||||
|
||||
|
||||
class ObjectInterface(metaclass=abc.ABCMeta):
|
||||
"""A base object required to be the ancestor of every object used in
|
||||
@@ -338,8 +308,6 @@ class Template:
|
||||
constructed at resolution time and then cached.
|
||||
"""
|
||||
|
||||
__slots__ = "_vol"
|
||||
|
||||
def __init__(self, type_name: str, **arguments) -> None:
|
||||
"""Stores the keyword arguments for later object creation."""
|
||||
# Allow the updating of template arguments whilst still in template form
|
||||
|
||||
Reference in New Issue
Block a user