MCPcopy
hub / github.com/csev/py4e / write_into

Method write_into

lectures/srt-split/pysrt/srtfile.py:232–254  ·  view source on GitHub ↗

write_into(output_file [, eol]) Serialize current state into `output_file`. `output_file` -> Any instance that respond to `write()`, typically a file object

(self, output_file, eol=None)

Source from the content-addressed store, hash-verified

230 save_file.close()
231
232 def write_into(self, output_file, eol=None):
233 """
234 write_into(output_file [, eol])
235
236 Serialize current state into `output_file`.
237
238 `output_file` -> Any instance that respond to `write()`, typically a
239 file object
240 """
241 output_eol = eol or self.eol
242
243 for item in self:
244 string_repr = str(item)
245 string_repr = string_repr.replace("None\n","1\n");
246 if output_eol != '\n':
247 string_repr = string_repr.replace('\n', output_eol)
248 output_file.write(string_repr)
249 # Only add trailing eol if it's not already present.
250 # It was kept in the SubRipItem's text before but it really
251 # belongs here. Existing applications might give us subtitles
252 # which already contain a trailing eol though.
253 if not string_repr.endswith(2 * output_eol):
254 output_file.write(output_eol)
255
256 @classmethod
257 def _guess_eol(cls, string_iterable):

Callers 4

saveMethod · 0.95
shiftMethod · 0.80
rateMethod · 0.80
break_linesMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected