Skip to content

Commit

Permalink
Code review: 261140043: Clean up docstrings and code.
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Dec 31, 2015
1 parent c3d2d84 commit bbc854c
Show file tree
Hide file tree
Showing 38 changed files with 942 additions and 773 deletions.
2 changes: 1 addition & 1 deletion config/dpkg/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ python-plaso (1.3.1-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline <[email protected]> Tue, 15 Sep 2015 07:16:33 +0200
-- Log2Timeline <[email protected]> Tue, 15 Sep 2015 20:56:42 +0200
93 changes: 61 additions & 32 deletions plaso/events/time_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ class TimestampEvent(event.EventObject):
Attributes:
data_type: the event data type.
timestamp: the timestamp, contains the number of microseconds from
January 1, 1970 00:00:00 UTC.
timestamp: the timestamp which is an integer containing the number
of micro seconds since January 1, 1970, 00:00:00 UTC.
timestamp_desc: the description of the usage of the timestamp.
"""

def __init__(self, timestamp, usage, data_type=None):
def __init__(self, timestamp, timestamp_description, data_type=None):
"""Initializes an event object.
Args:
timestamp: the timestamp value.
usage: the description of the usage of the time value.
timestamp: The timestamp which is an integer containing the number
of micro seconds since January 1, 1970, 00:00:00 UTC.
timestamp_description: The usage string for the timestamp value.
data_type: Optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
"""
super(TimestampEvent, self).__init__()
self.timestamp = timestamp
self.timestamp_desc = usage
self.timestamp_desc = timestamp_description

if data_type:
self.data_type = data_type
Expand All @@ -35,100 +36,128 @@ def __init__(self, timestamp, usage, data_type=None):
class CocoaTimeEvent(TimestampEvent):
"""Convenience class for a Cocoa time-based event."""

def __init__(self, cocoa_time, usage, data_type=None):
def __init__(self, cocoa_time, timestamp_description, data_type=None):
"""Initializes an event object.
Args:
cocoa_time: the Cocoa time value.
usage: the description of the usage of the time value.
timestamp_description: The usage string for the timestamp value.
data_type: optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
"""
super(CocoaTimeEvent, self).__init__(
timelib.Timestamp.FromCocoaTime(cocoa_time), usage,
timelib.Timestamp.FromCocoaTime(cocoa_time), timestamp_description,
data_type=data_type)


class DelphiTimeEvent(TimestampEvent):
"""Convenience class for a Delphi time-based event."""

def __init__(self, delphi_time, timestamp_description, data_type=None):
"""Initializes an event object.
Args:
delphi_time: the Delphi time value.
timestamp_description: The usage string for the timestamp value.
data_type: optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
"""
super(DelphiTimeEvent, self).__init__(
timelib.Timestamp.FromDelphiTime(delphi_time), timestamp_description,
data_type=data_type)


class FatDateTimeEvent(TimestampEvent):
"""Convenience class for a FAT date time-based event."""

def __init__(self, fat_date_time, usage, data_type=None):
def __init__(self, fat_date_time, timestamp_description, data_type=None):
"""Initializes an event object.
Args:
fat_date_time: the FAT date time value.
usage: the description of the usage of the time value.
timestamp_description: The usage string for the timestamp value.
data_type: optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
"""
super(FatDateTimeEvent, self).__init__(
timelib.Timestamp.FromFatDateTime(fat_date_time), usage,
timelib.Timestamp.FromFatDateTime(fat_date_time), timestamp_description,
data_type=data_type)


class FiletimeEvent(TimestampEvent):
"""Convenience class for a FILETIME timestamp-based event."""

def __init__(self, filetime, usage, data_type=None):
def __init__(self, filetime, timestamp_description, data_type=None):
"""Initializes an event object.
Args:
filetime: the FILETIME timestamp value.
usage: the description of the usage of the time value.
timestamp_description: The usage string for the timestamp value.
data_type: optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
"""
super(FiletimeEvent, self).__init__(
timelib.Timestamp.FromFiletime(filetime), usage, data_type=data_type)
timelib.Timestamp.FromFiletime(filetime), timestamp_description,
data_type=data_type)


class JavaTimeEvent(TimestampEvent):
"""Convenience class for a Java time-based event."""

def __init__(self, java_time, usage, data_type=None):
def __init__(self, java_time, timestamp_description, data_type=None):
"""Initializes an event object.
Args:
java_time: the Java time value.
usage: the description of the usage of the time value.
timestamp_description: The usage string for the timestamp value.
data_type: optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
"""
super(JavaTimeEvent, self).__init__(
timelib.Timestamp.FromJavaTime(java_time), usage, data_type=data_type)
timelib.Timestamp.FromJavaTime(java_time), timestamp_description,
data_type=data_type)


class PosixTimeEvent(TimestampEvent):
"""Convenience class for a POSIX time-based event."""

def __init__(self, posix_time, usage, data_type=None):
def __init__(
self, posix_time, timestamp_description, data_type=None, micro_seconds=0):
"""Initializes an event object.
Args:
posix_time: the POSIX time value.
usage: the description of the usage of the time value.
posix_time: the POSIX time value, which contains the number of seconds
since January 1, 1970 00:00:00 UTC.
timestamp_description: The usage string for the timestamp value.
data_type: optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
micro_seconds: optional number of micro seconds.
"""
if micro_seconds:
timestamp = timelib.Timestamp.FromPosixTimeWithMicrosecond(
posix_time, micro_seconds)
else:
timestamp = timelib.Timestamp.FromPosixTime(posix_time)

super(PosixTimeEvent, self).__init__(
timelib.Timestamp.FromPosixTime(posix_time), usage, data_type=data_type)
timestamp, timestamp_description, data_type=data_type)


class PythonDatetimeEvent(TimestampEvent):
"""Convenience class for a Python DateTime time-based event."""

def __init__(self, datetime_time, usage, data_type=None):
def __init__(self, datetime_time, timestamp_description, data_type=None):
"""Initializes an event object.
Args:
datetime_time: the datetime object (instance of datetime.datetime).
usage: the description of the usage of the time value.
timestamp_description: The usage string for the timestamp value.
data_type: optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
"""
super(PythonDatetimeEvent, self).__init__(
timelib.Timestamp.FromPythonDatetime(datetime_time), usage,
data_type=data_type)
timelib.Timestamp.FromPythonDatetime(datetime_time),
timestamp_description, data_type=data_type)


class UUIDTimeEvent(TimestampEvent):
Expand All @@ -138,12 +167,12 @@ class UUIDTimeEvent(TimestampEvent):
mac_address: the MAC address stored in the UUID.
"""

def __init__(self, uuid, usage):
def __init__(self, uuid, timestamp_description):
"""Initializes an event object.
Args:
uuid: a uuid object (instance of uuid.UUID).
usage: the description of the usage of the time value.
timestamp_description: The usage string for the timestamp value.
Raises:
ValueError: if the UUID version is not supported.
Expand All @@ -155,7 +184,7 @@ def __init__(self, uuid, usage):
mac_address = u'{0:s}:{1:s}:{2:s}:{3:s}:{4:s}:{5:s}'.format(
uuid.hex[20:22], uuid.hex[22:24], uuid.hex[24:26], uuid.hex[26:28],
uuid.hex[28:30], uuid.hex[30:32])
super(UUIDTimeEvent, self).__init__(timestamp, usage)
super(UUIDTimeEvent, self).__init__(timestamp, timestamp_description)

self.mac_address = mac_address
self.uuid = u'{0!s}'.format(uuid)
Expand All @@ -164,15 +193,15 @@ def __init__(self, uuid, usage):
class WebKitTimeEvent(TimestampEvent):
"""Convenience class for a WebKit time-based event."""

def __init__(self, webkit_time, usage, data_type=None):
def __init__(self, webkit_time, timestamp_description, data_type=None):
"""Initializes an event object.
Args:
webkit_time: the WebKit time value.
usage: the description of the usage of the time value.
timestamp_description: The usage string for the timestamp value.
data_type: optional event data type. If not set data_type is
derived from the DATA_TYPE attribute.
"""
super(WebKitTimeEvent, self).__init__(
timelib.Timestamp.FromWebKitTime(webkit_time), usage,
timelib.Timestamp.FromWebKitTime(webkit_time), timestamp_description,
data_type=data_type)
4 changes: 0 additions & 4 deletions plaso/lib/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ def __init__(self, state_regex, regex, actions, next_state, flags=re.I):

self.next_state = next_state

def Action(self, unused_lexer):
"""Method is called when the token matches."""
pass


class Lexer(object):
"""A generic feed lexer."""
Expand Down
5 changes: 2 additions & 3 deletions plaso/lib/pfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ def __init__(self, data):
"""Take a date object and use that for comparison.
Args:
data: A string, datetime object or an integer that
represents the time to compare against. Time should be stored
as microseconds since UTC in Epoch format.
data: A string, datetime object or an integer containing the number
of micro seconds since January 1, 1970, 00:00:00 UTC.
Raises:
ValueError: if the date string is invalid.
Expand Down
Loading

0 comments on commit bbc854c

Please sign in to comment.