MCPcopy
hub / github.com/scrapy/scrapy / __init__

Method __init__

scrapy/exporters.py:127–139  ·  view source on GitHub ↗
(self, file: BytesIO, **kwargs: Any)

Source from the content-addressed store, hash-verified

125
126class JsonItemExporter(BaseItemExporter):
127 def __init__(self, file: BytesIO, **kwargs: Any):
128 super().__init__(dont_fail=True, **kwargs)
129 self.file: BytesIO = file
130 # there is a small difference between the behaviour or JsonItemExporter.indent
131 # and ScrapyJSONEncoder.indent. ScrapyJSONEncoder.indent=None is needed to prevent
132 # the addition of newlines everywhere
133 json_indent = (
134 self.indent if self.indent is not None and self.indent > 0 else None
135 )
136 self._kwargs.setdefault("indent", json_indent)
137 self._kwargs.setdefault("ensure_ascii", not self.encoding)
138 self.encoder = ScrapyJSONEncoder(**self._kwargs)
139 self.first_item = True
140
141 def _beautify_newline(self) -> None:
142 if self.indent is not None:

Callers

nothing calls this directly

Calls 3

ScrapyJSONEncoderClass · 0.90
__init__Method · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected