_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q25900
OutputManager.GetOutputClass
train
def GetOutputClass(cls, name): """Retrieves the output class for a specific name. Args: name (str): name of the output module. Returns: type: output module class. Raises: KeyError: if there is no output class found with the supplied name. ValueError: if name is not a string. ...
python
{ "resource": "" }
q25901
OutputManager.GetOutputClasses
train
def GetOutputClasses(cls): """Retrieves the available output classes its associated name. Yields: tuple[str, type]: output class name and type object. """
python
{ "resource": "" }
q25902
OutputManager.HasOutputClass
train
def HasOutputClass(cls, name): """Determines if a specific output class is registered with the manager. Args: name (str): name of the
python
{ "resource": "" }
q25903
OutputManager.IsLinearOutputModule
train
def IsLinearOutputModule(cls, name): """Determines if a specific output class is a linear output module. Args: name (str): name of the output module. Returns: True: if the output module is linear. """ name = name.lower() output_class = cls._output_classes.get(name, None) if no...
python
{ "resource": "" }
q25904
OutputManager.NewOutputModule
train
def NewOutputModule(cls, name, output_mediator): """Creates a new output module object for the specified output format. Args: name (str): name of the output module. output_mediator (OutputMediator): output mediator. Returns: OutputModule: output module. Raises: KeyError: if th...
python
{ "resource": "" }
q25905
OutputManager.RegisterOutput
train
def RegisterOutput(cls, output_class, disabled=False): """Registers an output class. The output classes are identified based on their NAME attribute. Args: output_class (type): output module class. disabled (Optional[bool]): True if the output module is disabled due to the module not...
python
{ "resource": "" }
q25906
OutputManager.RegisterOutputs
train
def RegisterOutputs(cls, output_classes, disabled=False): """Registers output classes. The output classes are identified based on their NAME attribute. Args: output_classes (list[type]): output module classes. disabled (Optional[bool]): True if the output module is disabled due to th...
python
{ "resource": "" }
q25907
CPUTimeMeasurement.SampleStart
train
def SampleStart(self): """Starts measuring the CPU time.""" self._start_cpu_time = time.clock()
python
{ "resource": "" }
q25908
CPUTimeMeasurement.SampleStop
train
def SampleStop(self): """Stops measuring the CPU time.""" if self._start_cpu_time is not None:
python
{ "resource": "" }
q25909
SampleFileProfiler._WritesString
train
def _WritesString(self, content): """Writes a string to the sample file. Args: content (str): content to write to the sample file. """ content_bytes
python
{ "resource": "" }
q25910
CPUTimeProfiler.StartTiming
train
def StartTiming(self, profile_name): """Starts timing CPU time. Args: profile_name (str): name of the profile to sample. """ if profile_name not in self._profile_measurements:
python
{ "resource": "" }
q25911
CPUTimeProfiler.StopTiming
train
def StopTiming(self, profile_name): """Stops timing CPU time. Args: profile_name (str): name of the profile to sample. """ measurements = self._profile_measurements.get(profile_name) if measurements: measurements.SampleStop()
python
{ "resource": "" }
q25912
StorageProfiler.Sample
train
def Sample(self, operation, description, data_size, compressed_data_size): """Takes a sample of data read or written for profiling. Args: operation (str): operation, either 'read' or 'write'. description (str): description of the data read. data_size (int): size of the data read in bytes. ...
python
{ "resource": "" }
q25913
TaskQueueProfiler.Sample
train
def Sample(self, tasks_status): """Takes a sample of the status of queued tasks for profiling. Args: tasks_status (TasksStatus): status information about tasks. """ sample_time = time.time() sample = '{0:f}\t{1:d}\t{2:d}\t{3:d}\t{4:d}\t{5:d}\n'.format( sample_time, tasks_status.number...
python
{ "resource": "" }
q25914
TasksProfiler.Sample
train
def Sample(self, task, status): """Takes a sample of the status of a task for profiling. Args: task (Task): a task. status (str): status. """
python
{ "resource": "" }
q25915
TimesketchOutputModule.Close
train
def Close(self): """Closes the connection to TimeSketch Elasticsearch database. Sends the remaining events for indexing and removes the processing status on the Timesketch search index object. """ super(TimesketchOutputModule, self).Close() with self._timesketch.app_context(): search_ind...
python
{ "resource": "" }
q25916
TimesketchOutputModule.SetTimelineName
train
def SetTimelineName(self, timeline_name): """Sets the timeline name. Args: timeline_name (str): timeline name. """
python
{ "resource": "" }
q25917
TimesketchOutputModule.SetTimelineOwner
train
def SetTimelineOwner(self, username): """Sets the username of the user that should own the timeline. Args: username (str): username. """
python
{ "resource": "" }
q25918
TimesketchOutputModule.WriteHeader
train
def WriteHeader(self): """Sets up the Elasticsearch index and the Timesketch database object. Creates the Elasticsearch index with Timesketch specific settings and the Timesketch SearchIndex database object. """ # This cannot be static because we use the value of self._document_type # from argu...
python
{ "resource": "" }
q25919
BaseFirefoxCacheParser._ParseHTTPHeaders
train
def _ParseHTTPHeaders(self, header_data, offset, display_name): """Extract relevant information from HTTP header. Args: header_data (bytes): HTTP header data. offset (int): offset of the cache record, relative to the start of the Firefox cache file. display_name (str): display name ...
python
{ "resource": "" }
q25920
FirefoxCacheParser._GetFirefoxConfig
train
def _GetFirefoxConfig(self, file_object, display_name): """Determine cache file block size. Args: file_object (dfvfs.FileIO): a file-like object. display_name (str): display name. Returns: firefox_cache_config: namedtuple containing the block size and first record offset. ...
python
{ "resource": "" }
q25921
FirefoxCacheParser._ReadCacheEntry
train
def _ReadCacheEntry(self, file_object, display_name, block_size): """Reads a cache entry. Args: file_object (dfvfs.FileIO): a file-like object. display_name (str): display name. block_size (int): block size. Returns: tuple: containing: firefox_cache1_entry_header: cache re...
python
{ "resource": "" }
q25922
FirefoxCacheParser._ValidateCacheEntryHeader
train
def _ValidateCacheEntryHeader(self, cache_entry_header): """Determines whether the values in the cache entry header are valid. Args: cache_entry_header (firefox_cache1_entry_header): cache entry header. Returns: bool: True if the cache entry header is valid. """ return ( cache_...
python
{ "resource": "" }
q25923
FirefoxCache2Parser._GetCacheFileMetadataHeaderOffset
train
def _GetCacheFileMetadataHeaderOffset(self, file_object): """Determines the offset of the cache file metadata header. This method is inspired by the work of James Habben: https://github.com/JamesHabben/FirefoxCache2 Args: file_object (dfvfs.FileIO): a file-like object. Returns: int:...
python
{ "resource": "" }
q25924
FirefoxCache2Parser._ValidateCacheFileMetadataHeader
train
def _ValidateCacheFileMetadataHeader(self, cache_file_metadata_header): """Determines whether the cache file metadata header is valid. Args: cache_file_metadata_header (firefox_cache2_file_metadata_header): cache file metadata header. Returns: bool: True if the cache file metadata he...
python
{ "resource": "" }
q25925
PsortTool._CheckStorageFile
train
def _CheckStorageFile(self, storage_file_path): # pylint: disable=arguments-differ """Checks if the storage file path is valid. Args: storage_file_path (str): path of the storage file. Raises: BadConfigOption: if the storage file path is invalid. """ if os.path.exists(storage_file_pat...
python
{ "resource": "" }
q25926
PsortTool._GetAnalysisPlugins
train
def _GetAnalysisPlugins(self, analysis_plugins_string): """Retrieves analysis plugins. Args: analysis_plugins_string (str): comma separated names of analysis plugins to enable. Returns: list[AnalysisPlugin]: analysis plugins. """ if not analysis_plugins_string: return [...
python
{ "resource": "" }
q25927
PsortTool._ParseAnalysisPluginOptions
train
def _ParseAnalysisPluginOptions(self, options): """Parses the analysis plugin options. Args: options (argparse.Namespace): command line arguments. """ # Get a list of all available plugins. analysis_plugin_info = self._analysis_manager.GetAllPluginInformation() # Use set-comprehension to ...
python
{ "resource": "" }
q25928
PsortTool.AddProcessingOptions
train
def AddProcessingOptions(self, argument_group): """Adds processing options to the argument group Args: argument_group (argparse._ArgumentGroup): argparse argument group. """ argument_helper_names = ['temporary_directory', 'zeromq'] if self._CanEnforceProcessMemoryLimit(): argument_helpe...
python
{ "resource": "" }
q25929
PsortTool.ProcessStorage
train
def ProcessStorage(self): """Processes a plaso storage file. Raises: BadConfigOption: when a configuration parameter fails validation. RuntimeError: if a non-recoverable situation is encountered. """ self._CheckStorageFile(self._storage_file_path) self._status_view.SetMode(self._status...
python
{ "resource": "" }
q25930
BencodePlugin._GetKeys
train
def _GetKeys(self, data, keys, depth=1): """Helper function to return keys nested in a bencode dict. By default this function will return the values for the named keys requested by a plugin in match{}. The default setting is to look a single layer down from the root (same as the check for plugin applic...
python
{ "resource": "" }
q25931
BencodePlugin._RecurseKey
train
def _RecurseKey(self, recur_item, root='', depth=15): """Flattens nested dictionaries and lists by yielding their values. The hierarchy of a bencode file is a series of nested dictionaries and lists. This is a helper function helps plugins navigate the structure without having to reimplement their own ...
python
{ "resource": "" }
q25932
SQLiteStorageMergeReader._GetContainerTypes
train
def _GetContainerTypes(self): """Retrieves the container types to merge. Container types not defined in _CONTAINER_TYPES are ignored and not merged. Specific container types reference other container types, such as event referencing event data. The names are ordered to ensure the attribute contain...
python
{ "resource": "" }
q25933
SQLiteStorageMergeReader._Open
train
def _Open(self): """Opens the task storage for reading.""" self._connection = sqlite3.connect( self._path,
python
{ "resource": "" }
q25934
SQLiteStorageMergeReader._ReadStorageMetadata
train
def _ReadStorageMetadata(self): """Reads the task storage metadata.""" query = 'SELECT key, value FROM metadata'
python
{ "resource": "" }
q25935
SQLiteStorageMergeReader._PrepareForNextContainerType
train
def _PrepareForNextContainerType(self): """Prepares for the next container type. This method prepares the task storage for merging the next container type. It set the active container type, its add method and active cursor accordingly. """ self._active_container_type = self._container_types.pop...
python
{ "resource": "" }
q25936
SQLiteStorageMergeReader.MergeAttributeContainers
train
def MergeAttributeContainers( self, callback=None, maximum_number_of_containers=0): """Reads attribute containers from a task storage file into the writer. Args: callback (function[StorageWriter, AttributeContainer]): function to call after each attribute container is deserialized. ...
python
{ "resource": "" }
q25937
MacWifiLogParser._GetAction
train
def _GetAction(self, action, text): """Parse the well known actions for easy reading. Args: action (str): the function or action called by the agent. text (str): mac Wifi log text. Returns: str: a formatted string representing the known (or common) action. If the action is no...
python
{ "resource": "" }
q25938
MacWifiLogParser.VerifyStructure
train
def VerifyStructure(self, parser_mediator, line): """Verify that this file is a Mac Wifi log file. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. line (str): line from a text file. Returns: bool: Tr...
python
{ "resource": "" }
q25939
AutomaticDestinationsOLECFPlugin._ParseDistributedTrackingIdentifier
train
def _ParseDistributedTrackingIdentifier( self, parser_mediator, uuid_object, origin): """Extracts data from a Distributed Tracking identifier. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. uuid_object (...
python
{ "resource": "" }
q25940
AutomaticDestinationsOLECFPlugin.ParseDestList
train
def ParseDestList(self, parser_mediator, olecf_item): """Parses the DestList OLECF item. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. olecf_item (pyolecf.item): OLECF item. Raises: UnableToParseFi...
python
{ "resource": "" }
q25941
ParserMediator._GetEarliestYearFromFileEntry
train
def _GetEarliestYearFromFileEntry(self): """Retrieves the year from the file entry date and time values. This function uses the creation time if available otherwise the change time (metadata last modification time) is used. Returns: int: year of the file entry or None. """ file_entry = s...
python
{ "resource": "" }
q25942
ParserMediator._GetInode
train
def _GetInode(self, inode_value): """Retrieves the inode from the inode value. Args: inode_value (int|str): inode, such as 1 or '27-128-1'. Returns: int: inode or -1 if the inode value cannot be converted to an integer. """ if isinstance(inode_value, py2to3.INTEGER_TYPES): return...
python
{ "resource": "" }
q25943
ParserMediator.AddEventAttribute
train
def AddEventAttribute(self, attribute_name, attribute_value): """Adds an attribute that will be set on all events produced. Setting attributes using this method will cause events produced via this mediator to have an attribute with the provided name set with the provided value. Args: attribu...
python
{ "resource": "" }
q25944
ParserMediator.GetDisplayName
train
def GetDisplayName(self, file_entry=None): """Retrieves the display name for a file entry. Args: file_entry (Optional[dfvfs.FileEntry]): file entry object, where None will return the display name of self._file_entry. Returns: str: human readable string that describes the path to the ...
python
{ "resource": "" }
q25945
ParserMediator.GetEstimatedYear
train
def GetEstimatedYear(self): """Retrieves an estimate of the year. This function determines the year in the following manner: * see if the user provided a preferred year; * see if knowledge base defines a year e.g. derived from preprocessing; * determine the year based on the file entry metadata; ...
python
{ "resource": "" }
q25946
ParserMediator.GetFilename
train
def GetFilename(self): """Retrieves the name of the active file entry. Returns: str: name of the active file entry or None. """ if not self._file_entry: return None data_stream = getattr(self._file_entry.path_spec, 'data_stream',
python
{ "resource": "" }
q25947
ParserMediator.ProcessEvent
train
def ProcessEvent( self, event, parser_chain=None, file_entry=None, query=None): """Processes an event before it written to the storage. Args: event (EventObject|EventData): event or event data. parser_chain (Optional[str]): parsing chain up to this point. file_entry (Optional[dfvfs.File...
python
{ "resource": "" }
q25948
ParserMediator.ProduceEventSource
train
def ProduceEventSource(self, event_source): """Produces an event source. Args: event_source (EventSource): an event source. Raises: RuntimeError: when storage writer
python
{ "resource": "" }
q25949
ParserMediator.ProduceExtractionWarning
train
def ProduceExtractionWarning(self, message, path_spec=None): """Produces an extraction warning. Args: message (str): message of the warning. path_spec (Optional[dfvfs.PathSpec]): path specification, where None will use the path specification of current file entry set in the medi...
python
{ "resource": "" }
q25950
ParserMediator.RemoveEventAttribute
train
def RemoveEventAttribute(self, attribute_name): """Removes an attribute from being set on all events produced. Args: attribute_name (str): name of the attribute to remove.
python
{ "resource": "" }
q25951
ParserMediator.SampleMemoryUsage
train
def SampleMemoryUsage(self, parser_name): """Takes a sample of the memory usage for profiling. Args: parser_name (str): name of the parser. """ if self._memory_profiler:
python
{ "resource": "" }
q25952
ParserMediator.SetInputSourceConfiguration
train
def SetInputSourceConfiguration(self, configuration): """Sets the input source configuration settings. Args: configuration (InputSourceConfiguration): input source configuration. """ mount_path = configuration.mount_path # Remove a trailing path separator from the mount path so the relative ...
python
{ "resource": "" }
q25953
ParserMediator.SetStorageWriter
train
def SetStorageWriter(self, storage_writer): """Sets the storage writer. Args: storage_writer (StorageWriter): storage writer. """ self._storage_writer = storage_writer # Reset the last event data information. Each storage file should
python
{ "resource": "" }
q25954
EventObjectFilter.CompileFilter
train
def CompileFilter(self, filter_expression): """Compiles the filter expression. The filter expression contains an object filter expression. Args: filter_expression (str): filter expression.
python
{ "resource": "" }
q25955
EventObjectFilter.Match
train
def Match(self, event): """Determines if an event matches the filter. Args: event (EventObject): an event. Returns: bool: True if the event matches the filter.
python
{ "resource": "" }
q25956
StatusView._AddsAnalysisProcessStatusTableRow
train
def _AddsAnalysisProcessStatusTableRow(self, process_status, table_view): """Adds an analysis process status table row. Args: process_status (ProcessStatus): processing status. table_view (CLITabularTableView): table view. """ used_memory = self._FormatSizeInUnitsOf1024(process_status.used_...
python
{ "resource": "" }
q25957
StatusView._AddExtractionProcessStatusTableRow
train
def _AddExtractionProcessStatusTableRow(self, process_status, table_view): """Adds an extraction process status table row. Args: process_status (ProcessStatus): processing status. table_view (CLITabularTableView): table view. """ used_memory = self._FormatSizeInUnitsOf1024(process_status.us...
python
{ "resource": "" }
q25958
StatusView._FormatSizeInUnitsOf1024
train
def _FormatSizeInUnitsOf1024(self, size): """Represents a number of bytes in units of 1024. Args: size (int): size in bytes. Returns: str: human readable string of the size. """ magnitude_1024 = 0 used_memory_1024 = float(size) while used_memory_1024 >= 1024: used_memory_...
python
{ "resource": "" }
q25959
StatusView._PrintAnalysisStatusHeader
train
def _PrintAnalysisStatusHeader(self, processing_status): """Prints the analysis status header. Args: processing_status (ProcessingStatus): processing status. """ self._output_writer.Write( 'Storage file\t\t: {0:s}\n'.format(self._storage_file_path)) self._PrintProcessingTime(processi...
python
{ "resource": "" }
q25960
StatusView._PrintAnalysisStatusUpdateLinear
train
def _PrintAnalysisStatusUpdateLinear(self, processing_status): """Prints an analysis status update in linear mode. Args: processing_status (ProcessingStatus): processing status. """ for worker_status in processing_status.workers_status: status_line = ( '{0:s} (PID: {1:d}) - events...
python
{ "resource": "" }
q25961
StatusView._PrintAnalysisStatusUpdateWindow
train
def _PrintAnalysisStatusUpdateWindow(self, processing_status): """Prints an analysis status update in window mode. Args: processing_status (ProcessingStatus): processing status. """ if self._stdout_output_writer: self._ClearScreen() output_text = 'plaso - {0:s} version {1:s}\n\n'.forma...
python
{ "resource": "" }
q25962
StatusView._PrintExtractionStatusUpdateLinear
train
def _PrintExtractionStatusUpdateLinear(self, processing_status): """Prints an extraction status update in linear mode. Args: processing_status (ProcessingStatus): processing status. """ for worker_status in processing_status.workers_status: status_line = (
python
{ "resource": "" }
q25963
StatusView._PrintExtractionStatusUpdateWindow
train
def _PrintExtractionStatusUpdateWindow(self, processing_status): """Prints an extraction status update in window mode. Args: processing_status (ProcessingStatus): processing status. """ if self._stdout_output_writer: self._ClearScreen() output_text = 'plaso - {0:s} version {1:s}\n\n'.f...
python
{ "resource": "" }
q25964
StatusView._PrintEventsStatus
train
def _PrintEventsStatus(self, events_status): """Prints the status of the events. Args: events_status (EventsStatus): events status. """ if events_status: table_view = views.CLITabularTableView( column_names=['Events:', 'Filtered', 'In time slice', 'Duplicates',
python
{ "resource": "" }
q25965
StatusView._PrintProcessingTime
train
def _PrintProcessingTime(self, processing_status): """Prints the processing time. Args: processing_status (ProcessingStatus): processing status. """ if not processing_status: processing_time = '00:00:00' else: processing_time = time.time() - processing_status.start_time
python
{ "resource": "" }
q25966
StatusView._PrintTasksStatus
train
def _PrintTasksStatus(self, processing_status): """Prints the status of the tasks. Args: processing_status (ProcessingStatus): processing status. """ if processing_status and processing_status.tasks_status: tasks_status = processing_status.tasks_status table_view = views.CLITabularTa...
python
{ "resource": "" }
q25967
StatusView.GetAnalysisStatusUpdateCallback
train
def GetAnalysisStatusUpdateCallback(self): """Retrieves the analysis status update callback function. Returns: function: status update callback function or None if not available. """ if self._mode == self.MODE_LINEAR:
python
{ "resource": "" }
q25968
StatusView.GetExtractionStatusUpdateCallback
train
def GetExtractionStatusUpdateCallback(self): """Retrieves the extraction status update callback function. Returns: function: status update callback function or None if not available. """ if self._mode ==
python
{ "resource": "" }
q25969
StatusView.PrintExtractionStatusHeader
train
def PrintExtractionStatusHeader(self, processing_status): """Prints the extraction status header. Args: processing_status (ProcessingStatus): processing status. """ self._output_writer.Write( 'Source path\t\t: {0:s}\n'.format(self._source_path)) self._output_writer.Write( 'Sou...
python
{ "resource": "" }
q25970
StatusView.PrintExtractionSummary
train
def PrintExtractionSummary(self, processing_status): """Prints a summary of the extraction. Args: processing_status (ProcessingStatus): processing status. """ if not processing_status: self._output_writer.Write( 'WARNING: missing processing status information.\n') elif not pr...
python
{ "resource": "" }
q25971
StatusView.SetSourceInformation
train
def SetSourceInformation( self, source_path, source_type, artifact_filters=None, filter_file=None): """Sets the source information. Args: source_path (str): path of the source. source_type (str): source type. artifact_filters (Optional[list[str]]): names of artifact definitions to ...
python
{ "resource": "" }
q25972
EventTagIndex._Build
train
def _Build(self, storage_file): """Builds the event tag index. Args: storage_file (BaseStorageFile): storage file. """ self._index = {}
python
{ "resource": "" }
q25973
EventTagIndex.GetEventTagByIdentifier
train
def GetEventTagByIdentifier(self, storage_file, event_identifier): """Retrieves the most recently updated event tag for an event. Args: storage_file (BaseStorageFile): storage file. event_identifier (AttributeContainerIdentifier): event attribute container identifier. Returns: ...
python
{ "resource": "" }
q25974
EventTagIndex.SetEventTag
train
def SetEventTag(self, event_tag): """Sets an event tag in the index. Args: event_tag (EventTag): event tag. """ event_identifier = event_tag.GetEventIdentifier()
python
{ "resource": "" }
q25975
PathHelper._ExpandUsersHomeDirectoryPathSegments
train
def _ExpandUsersHomeDirectoryPathSegments( cls, path_segments, path_separator, user_accounts): """Expands a path to contain all users home or profile directories. Expands the artifacts path variable "%%users.homedir%%" or "%%users.userprofile%%". Args: path_segments (list[str]): path segme...
python
{ "resource": "" }
q25976
PathHelper._IsWindowsDrivePathSegment
train
def _IsWindowsDrivePathSegment(cls, path_segment): """Determines if the path segment contains a Windows Drive indicator. A drive indicator can be a drive letter or %SystemDrive%. Args: path_segment (str): path segment. Returns: bool: True if the path segment contains a Windows Drive indic...
python
{ "resource": "" }
q25977
PathHelper.AppendPathEntries
train
def AppendPathEntries( cls, path, path_separator, number_of_wildcards, skip_first): """Appends glob wildcards to a path. This function will append glob wildcards "*" to a path, returning paths with an additional glob wildcard up to the specified number. E.g. given the path "/tmp" and a number of ...
python
{ "resource": "" }
q25978
PathHelper.ExpandRecursiveGlobs
train
def ExpandRecursiveGlobs(cls, path, path_separator): """Expands recursive like globs present in an artifact path. If a path ends in '**', with up to two optional digits such as '**10', the '**' will recursively match all files and zero or more directories from the specified path. The optional digits in...
python
{ "resource": "" }
q25979
PathHelper.ExpandWindowsPath
train
def ExpandWindowsPath(cls, path, environment_variables): """Expands a Windows path containing environment variables. Args: path (str): Windows path with environment variables. environment_variables (list[EnvironmentVariableArtifact]): environment variables. Returns: str: expand...
python
{ "resource": "" }
q25980
PathHelper.GetDisplayNameForPathSpec
train
def GetDisplayNameForPathSpec( cls, path_spec, mount_path=None, text_prepend=None): """Retrieves the display name of a path specification. Args: path_spec (dfvfs.PathSpec): path specification. mount_path (Optional[str]): path where the file system that is used by the path specificat...
python
{ "resource": "" }
q25981
PathHelper.GetRelativePathForPathSpec
train
def GetRelativePathForPathSpec(cls, path_spec, mount_path=None): """Retrieves the relative path of a path specification. If a mount path is defined the path will be relative to the mount point, otherwise the path is relative to the root of the file system that is used by the path specification. Ar...
python
{ "resource": "" }
q25982
GetUnicodeString
train
def GetUnicodeString(value): """Attempts to convert the argument to a Unicode string. Args: value (list|int|bytes|str): value to convert. Returns: str: string representation of the argument. """ if isinstance(value, list): value = [GetUnicodeString(item) for item in value]
python
{ "resource": "" }
q25983
GenericBinaryOperator.Operate
train
def Operate(self, values): """Takes a list of values and if at least one matches, returns True.""" for val in values: try: if
python
{ "resource": "" }
q25984
ValueExpander.Expand
train
def Expand(self, obj, path): """Returns a list of all the values for the given path in the object obj. Given a path such as ["sub1", "sub2"] it returns all the values available in obj.sub1.sub2 as a list. sub1 and sub2 must be data attributes or properties. If sub1 returns a list of objects, or a ...
python
{ "resource": "" }
q25985
ContextExpression.SetExpression
train
def SetExpression(self, expression): """Set the expression.""" if isinstance(expression, lexer.Expression): self.args = [expression] else:
python
{ "resource": "" }
q25986
ContextExpression.Compile
train
def Compile(self, filter_implementation): """Compile the expression.""" arguments = [self.attribute] for argument in self.args: arguments.append(argument.Compile(filter_implementation)) expander = filter_implementation.FILTERS['ValueExpander']
python
{ "resource": "" }
q25987
Parser.FlipAllowed
train
def FlipAllowed(self): """Raise an error if the not keyword is used where it is not allowed.""" if not hasattr(self, 'flipped'): raise errors.ParseError('Not defined.') if not self.flipped: return if self.current_expression.operator: if not self.current_expression.operator.lower() in...
python
{ "resource": "" }
q25988
Parser.FlipLogic
train
def FlipLogic(self, **unused_kwargs): """Flip the boolean logic of the expression. If an expression is configured to return True when the condition is met this logic will flip that to False, and vice versa. """ if hasattr(self, 'flipped') and self.flipped: raise errors.ParseError( '...
python
{ "resource": "" }
q25989
Parser.InsertIntArg
train
def InsertIntArg(self, string='', **unused_kwargs): """Inserts an Integer argument.""" try: int_value =
python
{ "resource": "" }
q25990
Parser.Reduce
train
def Reduce(self): """Reduce the token stack into an AST.""" # Check for sanity if self.state != 'INITIAL' and self.state != 'BINARY': self.Error('Premature end of expression') length = len(self.stack) while length > 1: # Precedence order self._CombineParenthesis() self._Comb...
python
{ "resource": "" }
q25991
SpotlightPlugin.GetEntries
train
def GetEntries(self, parser_mediator, match=None, **unused_kwargs): """Extracts relevant Spotlight entries. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. match (Optional[dict[str: object]]): keys extracted fr...
python
{ "resource": "" }
q25992
SQLitePlugin._GetRowValue
train
def _GetRowValue(self, query_hash, row, value_name): """Retrieves a value from the row. Args: query_hash (int): hash of the query, that uniquely identifies the query that produced the row. row (sqlite3.Row): row. value_name (str): name of the value. Returns: object: value...
python
{ "resource": "" }
q25993
SQLitePlugin._HashRow
train
def _HashRow(cls, row): """Hashes the given row. Args: row (sqlite3.Row): row. Returns: int: hash value of the given row. """ values = [] for value in row: try: value = '{0!s}'.format(value) except UnicodeDecodeError: # In Python 2, blobs are "read-write...
python
{ "resource": "" }
q25994
SQLitePlugin._ParseQuery
train
def _ParseQuery(self, parser_mediator, database, query, callback, cache): """Queries a database and parses the results. Args: parser_mediator (ParserMediator): parser mediator. database (SQLiteDatabase): database. query (str): query. callback (function): function to invoke to parse an i...
python
{ "resource": "" }
q25995
SQLitePlugin.CheckSchema
train
def CheckSchema(self, database): """Checks the schema of a database with that defined in the plugin. Args: database (SQLiteDatabase): database. Returns: bool: True if the schema of the database matches that defined by the plugin, or False if the schemas do not match or no schema ...
python
{ "resource": "" }
q25996
SQLitePlugin.Process
train
def Process( self, parser_mediator, cache=None, database=None, **unused_kwargs): """Determine if this is the right plugin for this database. This function takes a SQLiteDatabase object and compares the list of required tables against the available tables in the database. If all the tables defined...
python
{ "resource": "" }
q25997
SQLiteStorageFile._AddAttributeContainer
train
def _AddAttributeContainer(self, container_type, attribute_container): """Adds an attribute container. Args: container_type (str): attribute container type. attribute_container (AttributeContainer): attribute container. Raises: IOError: if the attribute container cannot be serialized. ...
python
{ "resource": "" }
q25998
SQLiteStorageFile._AddSerializedEvent
train
def _AddSerializedEvent(self, event): """Adds an serialized event. Args: event (EventObject): event. Raises: IOError: if the event cannot be serialized. OSError: if the event cannot be serialized. """ identifier = identifiers.SQLTableIdentifier( self._CONTAINER_TYPE_EVENT...
python
{ "resource": "" }
q25999
SQLiteStorageFile._CheckStorageMetadata
train
def _CheckStorageMetadata(cls, metadata_values, check_readable_only=False): """Checks the storage metadata. Args: metadata_values (dict[str, str]): metadata values per key. check_readable_only (Optional[bool]): whether the store should only be checked to see if it can be read. If False, t...
python
{ "resource": "" }