mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-29 11:19:40 +02:00
Remove the TZ*Values and rely on datetime.datetime directly.
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
or in some other form. This module defines both the output format (:class:`TreeGrid`) and the renderer interface
|
||||
which can interact with a TreeGrid to produce suitable output."""
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import typing
|
||||
from abc import abstractmethod, ABCMeta
|
||||
|
||||
import collections
|
||||
|
||||
from volatility.framework import validity
|
||||
|
||||
Column = collections.namedtuple('Column', ['index', 'name', 'type'])
|
||||
@@ -81,22 +82,13 @@ class BaseAbsentValue(object):
|
||||
# We don't class these off a shared base, because the SimpleTypes must only
|
||||
# contain the types that the validator will accept (which would not include the base)
|
||||
|
||||
class TZAwareValue(datetime.datetime):
|
||||
"""Class for TZ-aware datetimes"""
|
||||
|
||||
|
||||
class TZNaiveValue(datetime.datetime):
|
||||
"""Class for TZ-aware datetimes"""
|
||||
|
||||
|
||||
_Type = typing.TypeVar("_Type")
|
||||
ColumnsType = typing.List[typing.Tuple[str, typing.Type]]
|
||||
SimpleTypes = typing.Union[typing.Type[int],
|
||||
typing.Type[str],
|
||||
typing.Type[float],
|
||||
typing.Type[bytes],
|
||||
typing.Type[TZAwareValue],
|
||||
typing.Type[TZNaiveValue],
|
||||
typing.Type[datetime.datetime],
|
||||
typing.Type[BaseAbsentValue]]
|
||||
VisitorSignature = typing.Callable[[TreeNode, _Type], _Type]
|
||||
|
||||
|
||||
@@ -61,18 +61,9 @@ class TreeNode(interfaces.renderers.TreeNode):
|
||||
column.name,
|
||||
type(val),
|
||||
column.type))
|
||||
if isinstance(val, (interfaces.renderers.TZAwareValue, interfaces.renderers.TZNaiveValue)):
|
||||
tznaive = val.tzinfo is None or val.tzinfo.utcoffset(val) is None
|
||||
if isinstance(val, interfaces.renderers.TZAwareValue) and tznaive:
|
||||
raise TypeError(
|
||||
"Values item with index {} is not a timezone aware datetime object as required by column {}".format(
|
||||
index,
|
||||
column.name))
|
||||
elif isinstance(val, interfaces.renderers.TZNaiveValue) and not tznaive:
|
||||
raise TypeError(
|
||||
"Values item with index {} is not a timezone naive datetime object as required by column {}".format(
|
||||
index,
|
||||
column.name))
|
||||
# TODO: Consider how to deal with timezone naive/aware datetimes (and alert plugin uses to be precise)
|
||||
# if isinstance(val, datetime.datetime):
|
||||
# tznaive = val.tzinfo is None or val.tzinfo.utcoffset(val) is None
|
||||
|
||||
@property
|
||||
def values(self) -> typing.Iterable[interfaces.renderers.SimpleTypes]:
|
||||
|
||||
Reference in New Issue
Block a user