MCPcopy
hub / github.com/scrapy/scrapy / normvalue

Method normvalue

scrapy/http/headers.py:47–59  ·  view source on GitHub ↗

Normalize values to bytes

(self, value: _RawValue | Iterable[_RawValue])

Source from the content-addressed store, hash-verified

45 return self._tobytes(key.title())
46
47 def normvalue(self, value: _RawValue | Iterable[_RawValue]) -> list[bytes]:
48 """Normalize values to bytes"""
49 _value: Iterable[_RawValue]
50 if value is None:
51 _value = []
52 elif isinstance(value, (str, bytes)):
53 _value = [value]
54 elif hasattr(value, "__iter__"):
55 _value = value
56 else:
57 _value = [value]
58
59 return [self._tobytes(x) for x in _value]
60
61 def _tobytes(self, x: _RawValue) -> bytes:
62 if isinstance(x, bytes):

Callers 3

updateMethod · 0.95
getlistMethod · 0.95
appendlistMethod · 0.95

Calls 1

_tobytesMethod · 0.95

Tested by

no test coverage detected