MCPcopy
hub / github.com/scrapy/scrapy / stat_file

Method stat_file

scrapy/pipelines/files.py:127–139  ·  view source on GitHub ↗
(
        self, path: str | PathLike[str], info: MediaPipeline.SpiderInfo
    )

Source from the content-addressed store, hash-verified

125 absolute_path.write_bytes(buf.getvalue())
126
127 def stat_file(
128 self, path: str | PathLike[str], info: MediaPipeline.SpiderInfo
129 ) -> StatInfo:
130 absolute_path = self._get_filesystem_path(path)
131 try:
132 last_modified = absolute_path.stat().st_mtime
133 except OSError:
134 return {}
135
136 with absolute_path.open("rb") as f:
137 checksum = _md5sum(f)
138
139 return {"last_modified": last_modified, "checksum": checksum}
140
141 def _get_filesystem_path(self, path: str | PathLike[str]) -> Path:
142 path_comps = _to_string(path).split("/")

Callers

nothing calls this directly

Calls 3

_get_filesystem_pathMethod · 0.95
_md5sumFunction · 0.85
openMethod · 0.45

Tested by

no test coverage detected