MCPcopy
hub / github.com/scrapy/scrapy / ReceivedDataProtocol

Class ReceivedDataProtocol

scrapy/core/downloader/handlers/ftp.py:55–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54
55class ReceivedDataProtocol(Protocol):
56 def __init__(self, filename: bytes | None = None):
57 self.__filename: bytes | None = filename
58 self.body: BinaryIO = (
59 Path(filename.decode()).open("wb") if filename else BytesIO()
60 )
61 self.size: int = 0
62
63 def dataReceived(self, data: bytes) -> None:
64 self.body.write(data)
65 self.size += len(data)
66
67 @property
68 def filename(self) -> bytes | None:
69 return self.__filename
70
71 def close(self) -> None:
72 if self.filename:
73 self.body.close()
74 else:
75 self.body.seek(0)
76
77
78_CODE_RE = re.compile(r"\d+")

Callers 1

download_requestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected