docstr: Get a data writer object, either a new object or from cache
  
  Returns
  -------
  BcolzMinuteBarWriter | BcolzDailyBarWriter
docstr_tok: ["Get","a","data","writer","object",",","either","a","new","object","or","from","cache","Returns","--","--","--","-","BcolzMinuteBarWriter","|","BcolzDailyBarWriter"]
code: def get_writer(self, start_dt, end_dt, data_frequency):
      """
      Get a data writer object, either a new object or from cache
  
      Returns
      -------
      BcolzMinuteBarWriter | BcolzDailyBarWriter
  
      """
      root = get_exchange_folder(self.exchange_name)
      path = BUNDLE_NAME_TEMPLATE.format(
          root=root, frequency=data_frequency
      )
  
      if path in self._writers:
          return self._writers[path]
  
      ensure_directory(path)
  
      if len(os.listdir(path)) > 0:
          metadata = BcolzMinuteBarMetadata.read(path)
  
          write_metadata = False
          if start_dt < metadata.start_session:
              write_metadata = True
              start_session = start_dt
          else:
              start_session = metadata.start_session
  
          if end_dt > metadata.end_session:
              write_metadata = True
  
              end_session = end_dt
          else:
              end_session = metadata.end_session
  
          self._writers[path] = BcolzExchangeBarWriter(
              rootdir=path,
              start_session=start_session,
              end_session=end_session,
              write_metadata=write_metadata,
              data_frequency=data_frequency,
          )
      else:
          self._writers[path] = BcolzExchangeBarWriter(
              rootdir=path,
              start_session=start_dt,
              end_session=end_dt,
              write_metadata=True,
              data_frequency=data_frequency,
          )
  
      return self._writers[path]
  
imports: import os
  import shutil
  from datetime import timedelta
  from functools import partial
  from itertools import chain
  from operator import is_not
  import numpy
  import pandas
  import pytz
  from catalyst import get_calendar
  from catalyst.assets._assets import TradingPair
  from catalyst.constants import DATE_TIME_FORMAT, AUTO_INGEST
  from catalyst.constants import LOG_LEVEL
  from catalyst.data.minute_bars import BcolzMinuteOverlappingData, BcolzMinuteBarMetadata
  from catalyst.exchange.exchange_bcolz import BcolzExchangeBarReader, BcolzExchangeBarWriter
  from catalyst.exchange.exchange_errors import EmptyValuesInBundleError, TempBundleNotFoundError, NoDataAvailableOnExchange, PricingDataNotLoadedError, DataCorruptionError, PricingDataValueError
  from catalyst.exchange.utils.bundle_utils import range_in_bundle, get_bcolz_chunk, get_df_from_arrays, get_assets
  from catalyst.exchange.utils.datetime_utils import get_start_dt, get_period_label, get_month_start_end, get_year_start_end
  from catalyst.exchange.utils.exchange_utils import get_exchange_folder, save_exchange_symbols, mixin_market_params, get_catalyst_symbol
  from catalyst.utils.cli import maybe_show_progress
  from catalyst.utils.paths import ensure_directory
  from logbook import Logger
  from pytz import UTC
  from six import itervalues
label_desc: Use image node_id 4 for calling the ExchangeBundle obj's underlying member method code with example usage: obj.get_writer(start_dt, end_dt, data_frequency) and returns: self, self