Returns a version string for the resource at the given path. This class method may be overridden by subclasses. The default implementation is a SHA-512 hash of the file's contents. .. versionadded:: 3.1
(cls, abspath: str)
| 2856 | |
| 2857 | @classmethod |
| 2858 | def get_content_version(cls, abspath: str) -> str: |
| 2859 | """Returns a version string for the resource at the given path. |
| 2860 | |
| 2861 | This class method may be overridden by subclasses. The |
| 2862 | default implementation is a SHA-512 hash of the file's contents. |
| 2863 | |
| 2864 | .. versionadded:: 3.1 |
| 2865 | """ |
| 2866 | data = cls.get_content(abspath) |
| 2867 | hasher = hashlib.sha512() |
| 2868 | if isinstance(data, bytes): |
| 2869 | hasher.update(data) |
| 2870 | else: |
| 2871 | for chunk in data: |
| 2872 | hasher.update(chunk) |
| 2873 | return hasher.hexdigest() |
| 2874 | |
| 2875 | def _stat(self) -> os.stat_result: |
| 2876 | assert self.absolute_path is not None |
no test coverage detected