def __init__(self, file_path_prefix,
               append_trailing_newlines=True,
               file_name_suffix='',
               num_shards=0,
               shard_name_template=None,
               validate=True,
               coder=coders.ToStringCoder()):
    if not isinstance(file_path_prefix, basestring):
      raise TypeError(
          '%s: file_path_prefix must be a string; got %r instead' %
          (self.__class__.__name__, file_path_prefix))
    if not isinstance(file_name_suffix, basestring):
      raise TypeError(
          '%s: file_name_suffix must be a string; got %r instead' %
          (self.__class__.__name__, file_name_suffix))

    # We initialize a file_path attribute containing just the prefix part for
    # local runner environment. For now, sharding is not supported in the local
    # runner and sharding options (template, num, suffix) are ignored.
    # The attribute is also used in the worker environment when we just write
    # to a specific file.
    # TODO(silviuc): Add support for file sharding in the local runner.
    self.file_path = file_path_prefix
    self.append_trailing_newlines = append_trailing_newlines
    self.coder = coder

    self.is_gcs_sink = self.file_path.startswith('gs://')

    self.file_name_prefix = file_path_prefix
    self.file_name_suffix = file_name_suffix
    self.num_shards = num_shards
    # TODO(silviuc): Update this when the service supports more patterns.
    if shard_name_template not in (None, '', '-SSSSS-of-NNNNN'):
      raise ValueError(
          'The shard_name_template argument must be an empty string or the '
          'pattern -SSSSS-of-NNNNN instead of %s' % shard_name_template)
    self.shard_name_template = (
        shard_name_template if shard_name_template is not None
        else '-SSSSS-of-NNNNN')
    # TODO(silviuc): Implement sink validation.
    self.validate = validate
Initialize a TextSink.
dataset/ETHPy150Open GoogleCloudPlatform/DataflowPythonSDK/google/cloud/dataflow/io/fileio.py/TextFileSink.__init__