MCPcopy Index your code
hub / github.com/nodejs/node / dump

Method dump

tools/inspector_protocol/jinja2/environment.py:1206–1233  ·  view source on GitHub ↗

Dump the complete stream into a file or file-like object. Per default unicode strings are written, if you want to encode before writing specify an `encoding`. Example usage:: Template('Hello {{ name }}!').stream(name='foo').dump('hello.html')

(self, fp, encoding=None, errors='strict')

Source from the content-addressed store, hash-verified

1204 self.disable_buffering()
1205
1206 def dump(self, fp, encoding=None, errors='strict'):
1207 """Dump the complete stream into a file or file-like object.
1208 Per default unicode strings are written, if you want to encode
1209 before writing specify an `encoding`.
1210
1211 Example usage::
1212
1213 Template('Hello {{ name }}!').stream(name='foo').dump('hello.html')
1214 """
1215 close = False
1216 if isinstance(fp, string_types):
1217 if encoding is None:
1218 encoding = 'utf-8'
1219 fp = open(fp, 'wb')
1220 close = True
1221 try:
1222 if encoding is not None:
1223 iterable = (x.encode(encoding, errors) for x in self)
1224 else:
1225 iterable = self
1226 if hasattr(fp, 'writelines'):
1227 fp.writelines(iterable)
1228 else:
1229 for item in iterable:
1230 fp.write(item)
1231 finally:
1232 if close:
1233 fp.close()
1234
1235 def disable_buffering(self):
1236 """Disable the output buffering."""

Callers

nothing calls this directly

Calls 4

encodeMethod · 0.80
closeMethod · 0.65
openFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected