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 .. versionchanged:: 6.4 Now returns an aware datetime object instead of a naive o
(self)
| 3090 | return stat_result.st_size |
| 3091 | |
| 3092 | def get_modified_time(self) -> Optional[datetime.datetime]: |
| 3093 | """Returns the time that ``self.absolute_path`` was last modified. |
| 3094 | |
| 3095 | May be overridden in subclasses. Should return a `~datetime.datetime` |
| 3096 | object or None. |
| 3097 | |
| 3098 | .. versionadded:: 3.1 |
| 3099 | |
| 3100 | .. versionchanged:: 6.4 |
| 3101 | Now returns an aware datetime object instead of a naive one. |
| 3102 | Subclasses that override this method may return either kind. |
| 3103 | """ |
| 3104 | stat_result = self._stat() |
| 3105 | # NOTE: Historically, this used stat_result[stat.ST_MTIME], |
| 3106 | # which truncates the fractional portion of the timestamp. It |
| 3107 | # was changed from that form to stat_result.st_mtime to |
| 3108 | # satisfy mypy (which disallows the bracket operator), but the |
| 3109 | # latter form returns a float instead of an int. For |
| 3110 | # consistency with the past (and because we have a unit test |
| 3111 | # that relies on this), we truncate the float here, although |
| 3112 | # I'm not sure that's the right thing to do. |
| 3113 | modified = datetime.datetime.fromtimestamp( |
| 3114 | int(stat_result.st_mtime), datetime.timezone.utc |
| 3115 | ) |
| 3116 | return modified |
| 3117 | |
| 3118 | def get_content_type(self) -> str: |
| 3119 | """Returns the ``Content-Type`` header to be used for this request. |