Last active
April 13, 2022 04:13
-
-
Save izikeros/e788a73f128237e8feccfaf7f361bb86 to your computer and use it in GitHub Desktop.
Create signature of file without reading it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import stat | |
| def _sig(st): | |
| """Create signatures of files without reading them. | |
| Can be used to determine if files are the same or not. | |
| Example: | |
| >>> s1 = _sig(os.stat(file_name)) | |
| """ | |
| # described: https://stackoverflow.com/a/9854699/3247880 | |
| # from: Mercurial source code: https://hg.python.org/cpython/file/2.7/Lib/filecmp.py | |
| return (stat.S_IFMT(st.st_mode), | |
| st.st_size, | |
| st.st_mtime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment