def TSKVolumeGetBytesPerSector(tsk_volume):
  """Retrieves the number of bytes per sector from a TSK volume object.

  Args:
    tsk_volume: a TSK volume object (instance of pytsk3.Volume_Info).

  Returns:
    The number of bytes per sector or 512 by default.
  """
  # Note that because pytsk3.Volume_Info does not explicitly defines info
  # we need to check if the attribute exists and has a value other
  # than None. Default to 512 otherwise.
  if hasattr(tsk_volume, u'info') and tsk_volume.info is not None:
    block_size = getattr(tsk_volume.info, u'block_size', 512)
  else:
    block_size = 512

  return block_size