original_docstring: Determines the volume path specification.
  
      Args:
        scan_context: the scan context (instance of dfvfs.ScanContext).
        partition_number: Optional preferred partition number. The default is
                          None.
        partition_offset: Optional preferred partition byte offset. The default
                          is None.
  
      Returns:
        The volume scan node (instance of dfvfs.SourceScanNode) or None
        if no supported partition was found.
  
      Raises:
        SourceScannerError: if the format of or within the source
                            is not supported or the the scan context
                            is invalid.
        RuntimeError: if the volume for a specific identifier cannot be
                      retrieved.
      
docstring: Determines the volume path specification.
docstring_tokens: Determines the volume path specification .
code: def _GetVolumeTSKPartition(
        self, scan_context, partition_number=None, partition_offset=None):
      """Determines the volume path specification.
  
      Args:
        scan_context: the scan context (instance of dfvfs.ScanContext).
        partition_number: Optional preferred partition number. The default is
                          None.
        partition_offset: Optional preferred partition byte offset. The default
                          is None.
  
      Returns:
        The volume scan node (instance of dfvfs.SourceScanNode) or None
        if no supported partition was found.
  
      Raises:
        SourceScannerError: if the format of or within the source
                            is not supported or the the scan context
                            is invalid.
        RuntimeError: if the volume for a specific identifier cannot be
                      retrieved.
      """
      if (not scan_context or not scan_context.last_scan_node or
          not scan_context.last_scan_node.path_spec):
        raise errors.SourceScannerError(u'Invalid scan context.')
  
      volume_system = tsk_volume_system.TSKVolumeSystem()
      volume_system.Open(scan_context.last_scan_node.path_spec)
  
      volume_identifiers = self._source_scanner.GetVolumeIdentifiers(
          volume_system)
      if not volume_identifiers:
        logging.info(u'No supported partitions found.')
        return
  
      if partition_number is not None and partition_number > 0:
        # Plaso uses partition numbers starting with 1 while dfvfs expects
        # the volume index to start with 0.
        volume = volume_system.GetVolumeByIndex(partition_number - 1)
        if volume:
          volume_location = u'/{0:s}'.format(volume.identifier)
          volume_scan_node = scan_context.last_scan_node.GetSubNodeByLocation(
              volume_location)
          if not volume_scan_node:
            raise RuntimeError(
                u'Unable to retrieve volume scan node by location: {0:s}'.format(
                    volume_location))
          return volume_scan_node
  
        logging.warning(u'No such partition: {0:d}.'.format(partition_number))
  
      if partition_offset is not None:
        for volume in volume_system.volumes:
          volume_extent = volume.extents[0]
          if volume_extent.offset == partition_offset:
            volume_location = u'/{0:s}'.format(volume.identifier)
            volume_scan_node = scan_context.last_scan_node.GetSubNodeByLocation(
                volume_location)
            if not volume_scan_node:
              raise RuntimeError((
                  u'Unable to retrieve volume scan node by location: '
                  u'{0:s}').format(volume_location))
            return volume_scan_node
  
        logging.warning(
            u'No such partition with offset: {0:d} (0x{0:08x}).'.format(
                partition_offset))
  
      if len(volume_identifiers) == 1:
        volume_location = u'/{0:s}'.format(volume_identifiers[0])
  
      else:
        try:
          selected_volume_identifier = self._GetPartionIdentifierFromUser(
              volume_system, volume_identifiers)
        except KeyboardInterrupt:
          raise errors.SourceScannerError(u'File system scan aborted.')
  
        volume = volume_system.GetVolumeByIdentifier(selected_volume_identifier)
        if not volume:
          raise RuntimeError(
              u'Unable to retrieve volume by identifier: {0:s}'.format(
                  selected_volume_identifier))
  
        volume_location = u'/{0:s}'.format(selected_volume_identifier)
  
      volume_scan_node = scan_context.last_scan_node.GetSubNodeByLocation(
          volume_location)
      if not volume_scan_node:
        raise RuntimeError(
            u'Unable to retrieve volume scan node by location: {0:s}'.format(
                volume_location))
      return volume_scan_node
code_tokens: def _GetVolumeTSKPartition ( self , scan_context , partition_number = None , partition_offset = None ) : if ( not scan_context or not scan_context . last_scan_node or not scan_context . last_scan_node . path_spec ) : raise errors . SourceScannerError ( u'Invalid scan context.' ) volume_system = tsk_volume_system . TSKVolumeSystem ( ) volume_system . Open ( scan_context . last_scan_node . path_spec ) volume_identifiers = self . _source_scanner . GetVolumeIdentifiers ( volume_system ) if not volume_identifiers : logging . info ( u'No supported partitions found.' ) return if partition_number is not None and partition_number > 0 : volume = volume_system . GetVolumeByIndex ( partition_number - 1 ) if volume : volume_location = u'/{0:s}' . format ( volume . identifier ) volume_scan_node = scan_context . last_scan_node . GetSubNodeByLocation ( volume_location ) if not volume_scan_node : raise RuntimeError ( u'Unable to retrieve volume scan node by location: {0:s}' . format ( volume_location ) ) return volume_scan_node logging . warning ( u'No such partition: {0:d}.' . format ( partition_number ) ) if partition_offset is not None : for volume in volume_system . volumes : volume_extent = volume . extents [ 0 ] if volume_extent . offset == partition_offset : volume_location = u'/{0:s}' . format ( volume . identifier ) volume_scan_node = scan_context . last_scan_node . GetSubNodeByLocation ( volume_location ) if not volume_scan_node : raise RuntimeError ( ( u'Unable to retrieve volume scan node by location: ' u'{0:s}' ) . format ( volume_location ) ) return volume_scan_node logging . warning ( u'No such partition with offset: {0:d} (0x{0:08x}).' . format ( partition_offset ) ) if len ( volume_identifiers ) == 1 : volume_location = u'/{0:s}' . format ( volume_identifiers [ 0 ] ) else : try : selected_volume_identifier = self . _GetPartionIdentifierFromUser ( volume_system , volume_identifiers ) except KeyboardInterrupt : raise errors . SourceScannerError ( u'File system scan aborted.' ) volume = volume_system . GetVolumeByIdentifier ( selected_volume_identifier ) if not volume : raise RuntimeError ( u'Unable to retrieve volume by identifier: {0:s}' . format ( selected_volume_identifier ) ) volume_location = u'/{0:s}' . format ( selected_volume_identifier ) volume_scan_node = scan_context . last_scan_node . GetSubNodeByLocation ( volume_location ) if not volume_scan_node : raise RuntimeError ( u'Unable to retrieve volume scan node by location: {0:s}' . format ( volume_location ) ) return volume_scan_node
short_docstring: Determines the volume path specification.
short_docstring_tokens: Determines the volume path specification .
comment: """Determines the volume path specification.
  
      Args:
        scan_context: the scan context (instance of dfvfs.ScanContext).
        partition_number: Optional preferred partition number. The default is
                          None.
        partition_offset: Optional preferred partition byte offset. The default
                          is None.
  
      Returns:
        The volume scan node (instance of dfvfs.SourceScanNode) or None
        if no supported partition was found.
  
      Raises:
        SourceScannerError: if the format of or within the source
                            is not supported or the the scan context
                            is invalid.
        RuntimeError: if the volume for a specific identifier cannot be
                      retrieved.
      """$SEP$# Plaso uses partition numbers starting with 1 while dfvfs expects$SEP$# the volume index to start with 0.