Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """The parser mediator object.""" | 2 """The parser mediator object.""" |
3 | 3 |
4 import logging | 4 import logging |
5 import os | 5 import os |
6 | 6 |
7 from plaso.containers import errors | 7 from plaso.containers import errors |
8 from plaso.engine import path_helper | 8 from plaso.engine import path_helper |
9 from plaso.lib import py2to3 | 9 from plaso.lib import py2to3 |
10 from plaso.lib import timelib | 10 from plaso.lib import timelib |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 year = timelib.GetYearFromPosixTime( | 186 year = timelib.GetYearFromPosixTime( |
187 posix_time, timezone=self._knowledge_base.timezone) | 187 posix_time, timezone=self._knowledge_base.timezone) |
188 return year | 188 return year |
189 except ValueError as exception: | 189 except ValueError as exception: |
190 logging.error(( | 190 logging.error(( |
191 u'Unable to determine creation year from file stat ' | 191 u'Unable to determine creation year from file stat ' |
192 u'information with error: {0:s}').format(exception)) | 192 u'information with error: {0:s}').format(exception)) |
193 return | 193 return |
194 | 194 |
195 def AddEventAttribute(self, attribute_name, attribute_value): | 195 def AddEventAttribute(self, attribute_name, attribute_value): |
196 """Add an attribute that will be set on all events produced. | 196 """Adds an attribute that will be set on all events produced. |
197 | 197 |
198 Setting attributes using this method will cause events produced via this | 198 Setting attributes using this method will cause events produced via this |
199 mediator to have an attribute with the provided name set with the | 199 mediator to have an attribute with the provided name set with the |
200 provided value. | 200 provided value. |
201 | 201 |
202 Args: | 202 Args: |
203 attribute_name (str): name of the attribute to set. | 203 attribute_name (str): name of the attribute to add. |
204 attribute_value (str): value of the attribute to set. | 204 attribute_value (str): value of the attribute to add. |
205 """ | 205 |
206 Raises: | |
207 KeyError: if the event attribute with is already set. | |
onager
2017/04/24 06:36:24
-with
Joachim Metz
2017/05/07 14:27:10
Done.
| |
208 """ | |
209 if attribute_name in self._extra_event_attributes: | |
210 raise KeyError(u'Event attribute {0:s} already set'.format( | |
211 attribute_name)) | |
212 | |
206 self._extra_event_attributes[attribute_name] = attribute_value | 213 self._extra_event_attributes[attribute_name] = attribute_value |
207 | 214 |
208 def AppendToParserChain(self, plugin_or_parser): | 215 def AppendToParserChain(self, plugin_or_parser): |
209 """Adds a parser or parser plugin to the parser chain. | 216 """Adds a parser or parser plugin to the parser chain. |
210 | 217 |
211 Args: | 218 Args: |
212 plugin_or_parser (BaseParser): parser or parser plugin. | 219 plugin_or_parser (BaseParser): parser or parser plugin. |
213 """ | 220 """ |
214 self._parser_chain_components.append(plugin_or_parser.NAME) | 221 self._parser_chain_components.append(plugin_or_parser.NAME) |
215 | 222 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 parser_chain = self.GetParserChain() | 502 parser_chain = self.GetParserChain() |
496 extraction_error = errors.ExtractionError( | 503 extraction_error = errors.ExtractionError( |
497 message=message, parser_chain=parser_chain, path_spec=path_spec) | 504 message=message, parser_chain=parser_chain, path_spec=path_spec) |
498 self._storage_writer.AddError(extraction_error) | 505 self._storage_writer.AddError(extraction_error) |
499 self._number_of_errors += 1 | 506 self._number_of_errors += 1 |
500 | 507 |
501 def RemoveEventAttribute(self, attribute_name): | 508 def RemoveEventAttribute(self, attribute_name): |
502 """Removes an attribute from being set on all events produced. | 509 """Removes an attribute from being set on all events produced. |
503 | 510 |
504 Args: | 511 Args: |
505 attribute_name (str): name of the attribute to set. | 512 attribute_name (str): name of the attribute to remove. |
506 """ | 513 |
507 if attribute_name in self._extra_event_attributes: | 514 Raises: |
508 del self._extra_event_attributes[attribute_name] | 515 KeyError: if the event attribute with is not set. |
onager
2017/04/24 06:36:24
-with
Joachim Metz
2017/05/07 14:27:10
Done.
| |
516 """ | |
517 if attribute_name not in self._extra_event_attributes: | |
518 raise KeyError(u'Event attribute: {0:s} not set'.format(attribute_name)) | |
519 | |
520 del self._extra_event_attributes[attribute_name] | |
509 | 521 |
510 def ResetFileEntry(self): | 522 def ResetFileEntry(self): |
511 """Resets the active file entry.""" | 523 """Resets the active file entry.""" |
512 self._file_entry = None | 524 self._file_entry = None |
513 | 525 |
514 def SetEventExtractionConfiguration(self, configuration): | 526 def SetEventExtractionConfiguration(self, configuration): |
515 """Sets the event extraction configuration settings. | 527 """Sets the event extraction configuration settings. |
516 | 528 |
517 Args: | 529 Args: |
518 configuration (EventExtractionConfiguration): event extraction | 530 configuration (EventExtractionConfiguration): event extraction |
(...skipping 29 matching lines...) Expand all Loading... | |
548 """Sets the storage writer. | 560 """Sets the storage writer. |
549 | 561 |
550 Args: | 562 Args: |
551 storage_writer (StorageWriter): storage writer. | 563 storage_writer (StorageWriter): storage writer. |
552 """ | 564 """ |
553 self._storage_writer = storage_writer | 565 self._storage_writer = storage_writer |
554 | 566 |
555 def SignalAbort(self): | 567 def SignalAbort(self): |
556 """Signals the parsers to abort.""" | 568 """Signals the parsers to abort.""" |
557 self._abort = True | 569 self._abort = True |
LEFT | RIGHT |