forked from log2timeline/plaso
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code review: 268880043: Separated table view from CLI tool log2timeli…
- Loading branch information
1 parent
a0b760b
commit 4ec808b
Showing
17 changed files
with
419 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ python-plaso (1.3.1-1) unstable; urgency=low | |
|
||
* Auto-generated | ||
|
||
-- Log2Timeline <[email protected]> Tue, 29 Sep 2015 22:18:57 +0200 | ||
-- Log2Timeline <[email protected]> Thu, 01 Oct 2015 21:45:47 +0200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
"""This file contains the definitions for analysis plugins.""" | ||
|
||
# All the possible analysis plugin types. | ||
|
||
# Plugin that detects anomalies. | ||
PLUGIN_TYPE_ANOMALY = 1 | ||
|
||
# Plugin that calculating statistical information. | ||
PLUGIN_TYPE_STATISTICS = 2 | ||
|
||
# Plugin that annotates (or tags) event objects. | ||
PLUGIN_TYPE_ANNOTATION = 3 | ||
|
||
# Pluging that provides summary information. | ||
PLUGIN_TYPE_REPORT = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# -*- coding: utf-8 -*- | ||
"""The CLI view classes.""" | ||
|
||
|
||
class CLITableView(object): | ||
"""Class that implements a 2 column command line table view.""" | ||
|
||
# The maximum width of the table in number of characters. | ||
# The standard width of Windows cmd.exe is 80 characters. | ||
_MAXIMUM_WIDTH = 80 | ||
|
||
_HEADER_FORMAT_STRING = u'{{0:*^{0:d}}}\n'.format(_MAXIMUM_WIDTH) | ||
|
||
def __init__(self, output_writer, column_width=25): | ||
"""Initializes the command line table view object. | ||
Args: | ||
output_writer: the output writer (instance of OutputWriter). | ||
The default is None which indicates the use of the stdout | ||
output writer. | ||
column_width: optional column width, which cannot be smaller than 0 or | ||
larger than the maximum width. | ||
Raises: | ||
ValueError: if the column width is out of bounds. | ||
""" | ||
if column_width < 0 or column_width > self._MAXIMUM_WIDTH: | ||
raise ValueError(u'Column width value out of bounds.') | ||
|
||
super(CLITableView, self).__init__() | ||
self._column_width = column_width | ||
self._output_writer = output_writer | ||
|
||
def PrintFooter(self): | ||
"""Prints the footer.""" | ||
self._output_writer.Write(u'-' * self._MAXIMUM_WIDTH) | ||
self._output_writer.Write(u'\n') | ||
|
||
def PrintHeader(self, text): | ||
"""Prints the header as a line with centered text. | ||
Args: | ||
text: The header text. | ||
""" | ||
self._output_writer.Write(u'\n') | ||
|
||
text = u' {0:s} '.format(text) | ||
header_string = self._HEADER_FORMAT_STRING.format(text) | ||
self._output_writer.Write(header_string) | ||
|
||
def PrintRow(self, first_column, second_column): | ||
"""Prints a row of 2 column values aligned to the column width. | ||
Args: | ||
first_column: the first column value. | ||
second_column: the second column value. | ||
""" | ||
maximum_row_width = self._MAXIMUM_WIDTH - self._column_width - 3 | ||
|
||
# The format string of the first line of the column value. | ||
primary_format_string = u'{{0:>{0:d}s}} : {{1:s}}\n'.format( | ||
self._column_width) | ||
|
||
# The format string of successive lines of the column value. | ||
secondary_format_string = u'{{0:<{0:d}s}}{{1:s}}\n'.format( | ||
self._column_width + 3) | ||
|
||
if len(second_column) < maximum_row_width: | ||
self._output_writer.Write(primary_format_string.format( | ||
first_column, second_column)) | ||
return | ||
|
||
# Split the column value in words. | ||
words = second_column.split() | ||
|
||
current = 0 | ||
|
||
lines = [] | ||
word_buffer = [] | ||
for word in words: | ||
current += len(word) + 1 | ||
if current >= maximum_row_width: | ||
current = len(word) | ||
lines.append(u' '.join(word_buffer)) | ||
word_buffer = [word] | ||
else: | ||
word_buffer.append(word) | ||
lines.append(u' '.join(word_buffer)) | ||
|
||
# Print the column value on multiple lines. | ||
self._output_writer.Write(primary_format_string.format( | ||
first_column, lines[0])) | ||
for line in lines[1:]: | ||
self._output_writer.Write(secondary_format_string.format(u'', line)) |
Oops, something went wrong.