Returns the time that ``self.absolute_path`` was last modified. May be overridden in subclasses. Should return a `~datetime.datetime` object or None. .. versionadded:: 3.1
(self)
| 2893 | return stat_result.st_size |
| 2894 | |
| 2895 | def get_modified_time(self) -> Optional[datetime.datetime]: |
| 2896 | """Returns the time that ``self.absolute_path`` was last modified. |
| 2897 | |
| 2898 | May be overridden in subclasses. Should return a `~datetime.datetime` |
| 2899 | object or None. |
| 2900 | |
| 2901 | .. versionadded:: 3.1 |
| 2902 | """ |
| 2903 | stat_result = self._stat() |
| 2904 | # NOTE: Historically, this used stat_result[stat.ST_MTIME], |
| 2905 | # which truncates the fractional portion of the timestamp. It |
| 2906 | # was changed from that form to stat_result.st_mtime to |
| 2907 | # satisfy mypy (which disallows the bracket operator), but the |
| 2908 | # latter form returns a float instead of an int. For |
| 2909 | # consistency with the past (and because we have a unit test |
| 2910 | # that relies on this), we truncate the float here, although |
| 2911 | # I'm not sure that's the right thing to do. |
| 2912 | modified = datetime.datetime.utcfromtimestamp(int(stat_result.st_mtime)) |
| 2913 | return modified |
| 2914 | |
| 2915 | def get_content_type(self) -> str: |
| 2916 | """Returns the ``Content-Type`` header to be used for this request. |