From dfb0975b3852998a4aadc3b13b3df628c5cb864a Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sat, 15 Sep 2012 08:10:49 -0400 Subject: [PATCH] add hash algorithm agility to RECORD --- pep-0376.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pep-0376.txt b/pep-0376.txt index 83d06ec02..bcd823ca0 100644 --- a/pep-0376.txt +++ b/pep-0376.txt @@ -218,11 +218,17 @@ Each record is composed of three elements: - an absolute path, using the local platform separator -- the **MD5** hash of the file, encoded in hex. Notice that `pyc` and `pyo` - generated files don't have any hash because they are automatically produced - from `py` files. So checking the hash of the corresponding `py` file is - enough to decide if the file and its associated `pyc` or `pyo` files have - changed. +- a hash of the file's contents. + Notice that `pyc` and `pyo` generated files don't have any hash because + they are automatically produced from `py` files. So checking the hash + of the corresponding `py` file is enough to decide if the file and + its associated `pyc` or `pyo` files have changed. + + The hash is either the empty string, the **MD5** hash of + the file, encoded in hex, or the hash algorithm as named in + ``hashlib.algorithms_guaranteed``, followed by the equals character + ``=``, followed by the urlsafe-base64-nopad encoding of the digest + (``base64.urlsafe_b64encode(digest)`` with trailing ``=`` removed). - the file's size in bytes @@ -391,9 +397,9 @@ contained in `METADATA` when it is instantiated. And following methods: -- ``get_installed_files(local=False)`` -> iterator of (path, md5, size) +- ``get_installed_files(local=False)`` -> iterator of (path, hash, size) - Iterates over the `RECORD` entries and return a tuple ``(path, md5, size)`` + Iterates over the `RECORD` entries and return a tuple ``(path, hash, size)`` for each line. If ``local`` is ``True``, the path is transformed into a local absolute path. Otherwise the raw value from `RECORD` is returned.