class_docstr: BytesCollection takes a buffer of bytes and maps that to
  a virtual file that can then be opened by fiona.
class_docstr_tok: ["BytesCollection","takes","a","buffer","of","bytes","and","maps","that","to","a","virtual","file","that","can","then","be","opened","by","fiona","."]
docstr: Takes buffer of bytes whose contents is something we'd like
  to open with Fiona and maps it to a virtual file.
docstr_tok: ["Takes","buffer","of","bytes","whose","contents","is","something","we","'d","like","to","open","with","Fiona","and","maps","it","to","a","virtual","file","."]
code: def __init__(self, bytesbuf, **kwds):
      """Takes buffer of bytes whose contents is something we'd like
      to open with Fiona and maps it to a virtual file.
  
      """
      self._closed = True
  
      if not isinstance(bytesbuf, bytes):
          raise ValueError("input buffer must be bytes")
  
      # Hold a reference to the buffer, as bad things will happen if
      # it is garbage collected while in use.
      self.bytesbuf = bytesbuf
  
      # Map the buffer to a file. If the buffer contains a zipfile
      # we take extra steps in naming the buffer and in opening
      # it. If the requested driver is for GeoJSON, we append an an
      # appropriate extension to ensure the driver reads it.
      filetype = get_filetype(self.bytesbuf)
      ext = ""
      if filetype == "zip":
          ext = ".zip"
      elif kwds.get("driver") == "GeoJSON":
          ext = ".json"
      self.virtual_file = buffer_to_virtual_file(self.bytesbuf, ext=ext)
  
      # Instantiate the parent class.
      super().__init__(self.virtual_file, vsi=filetype, **kwds)
      self._closed = False
  
imports: from contextlib import ExitStack
  import logging
  import os
  import warnings
  from fiona import compat, vfs
  from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
  from fiona.ogrext import Session, WritingSession
  from fiona.ogrext import buffer_to_virtual_file, remove_virtual_file, GEOMETRY_TYPES
  from fiona.errors import DriverError, DriverSupportError, GDALVersionError, SchemaError, UnsupportedGeometryTypeError, UnsupportedOperation
  from fiona.logutils import FieldSkipLogFilter
  from fiona.crs import CRS
  from fiona._env import get_gdal_release_name, get_gdal_version_tuple
  from fiona.env import env_ctx_if_needed
  from fiona.errors import FionaDeprecationWarning
  from fiona.drvsupport import driver_from_extension, supported_drivers, driver_mode_mingdal, _driver_converts_field_type_silently_to_str, _driver_supports_field
  from fiona.path import Path, vsi_path, parse_path
label_desc: Use image node_id 1 to create a new BytesCollection object from inherited base classes: Collection with example: obj = BytesCollection(bytesbuf)