

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()):
    "Initialize a TextSink.\n\n    Args:\n      file_path_prefix: The file path to write to. The files written will begin\n        with this prefix, followed by a shard identifier (see num_shards), and\n        end in a common extension, if given by file_name_suffix. In most cases,\n        only this argument is specified and num_shards, shard_name_template, and\n        file_name_suffix use default values.\n      append_trailing_newlines: indicate whether this sink should write an\n          additional newline char after writing each element.\n      file_name_suffix: Suffix for the files written.\n      num_shards: The number of files (shards) used for output. If not set, the\n        service will decide on the optimal number of shards.\n        Constraining the number of shards is likely to reduce\n        the performance of a pipeline.  Setting this value is not recommended\n        unless you require a specific number of output files.\n      shard_name_template: A template string containing placeholders for\n        the shard number and shard count. Currently only '' and\n        '-SSSSS-of-NNNNN' are patterns accepted by the service.\n        When constructing a filename for a particular shard number, the\n        upper-case letters 'S' and 'N' are replaced with the 0-padded shard\n        number and shard count respectively.  This argument can be '' in which\n        case it behaves as if num_shards was set to 1 and only one file will be\n        generated. The default pattern used is '-SSSSS-of-NNNNN'.\n      validate: Enable path validation on pipeline creation.\n      coder: Coder used to encode each line.\n\n    Raises:\n      TypeError: if file_path is not a string.\n      ValueError: if shard_name_template is not of expected format.\n    "
    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)))
    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
    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')
    self.validate = validate

dataset/ETHPy150Open GoogleCloudPlatform/DataflowPythonSDK/google/cloud/dataflow/io/fileio.py TextFileSink.__init__/original