class_docstr: Class for faking the NetCDF4 Filehandler.
docstr: Get a variable writer.
docstr_tok: ["Get","a","variable","writer","."]
code: def get_variable_writer(self, dset, settings):
      """Get a variable writer."""
      # use a variable path prefix:
      var_path = settings.get("variable_path", "")
  
      # Also keep track of the potential providers:
      providers = settings.get("providers", {})
  
      # list of ignored attribute names:
      ignored_attrs = [
          "path",
          "format",
          "shape",
          "default_data",
          "fill_value",
      ]
  
      # dictionary of dimensions:
      dims = settings.get("dimensions", {})
  
      def write_variable(vname, desc, sname=""):
          """Write a variable in our dataset."""
          # get numeric shape:
          shape_str = desc["shape"]
          shape = tuple([dims[dname] for dname in shape_str])
  
          # Get the desired data type:
          dtype = TYPE_MAP[desc["format"]]
  
          # Prepare a numpy array with the appropriate shape and type:
          data = np.zeros(shape, dtype=dtype)
  
          # Replace variable default path if applicable:
          vpath = set_variable_path(var_path, desc, sname)
  
          # Variable full name:
          full_name = f"{vpath}{vname}"
  
          # Add all the custom properties directly as attributes:
          attribs = {}
          add_attributes(attribs, ignored_attrs, desc)
  
          # Rename the fill value attribute:
          if "fill_value" in desc:
              attribs["_FillValue"] = desc["fill_value"]
  
          names = [vname, sname]
          details = [desc, providers, settings]
          populate_dummy_data(data, names, details)
  
          # Now we assign that data array:
          dset[full_name] = xr.DataArray(
              data, dims=shape_str, attrs=attribs
          )
  
          # Write the copy of the content:
          self.content[full_name] = data
  
      return write_variable
  
imports: from datetime import datetime
  import numpy
  import xarray
  from satpy.tests.reader_tests.test_netcdf_utils import FakeNetCDF4FileHandler
label_desc: Use image node_id 1 for calling the FakeLIFileHandlerBase obj's underlying member method code with example usage: obj.get_variable_writer(dset, settings) and returns: write_variable