From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Fri, 22 Jan 2016 09:49:23 -0700 Subject: [U-Boot] [PATCH 6/8] test/py: add various utility code In-Reply-To: References: <1453328158-23818-1-git-send-email-swarren@wwwdotorg.org> <1453328158-23818-6-git-send-email-swarren@wwwdotorg.org> Message-ID: <56A25D93.70500@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 01/21/2016 08:36 PM, Simon Glass wrote: > Hi Stephen, > > On 20 January 2016 at 15:15, Stephen Warren wrote: >> From: Stephen Warren >> >> Add various common utility functions. These will be used by a forthcoming >> re-written UMS test, and a brand-new DFU test. >> diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py >> +def md5sum_data(data): >> + '''Calculate the MD5 hash of some data. >> + >> + Args: >> + data: The data to hash. >> + >> + Returns: >> + The hash of the data, as a binary string. >> + ''' >> + >> + h = hashlib.md5() >> + h.update(data) >> + return h.digest() > > Or just: > > return hashlib.md5().update(data).digest() I was going to do that, but it doesn't look like update() returns the hash object, so I can't chain at least the .digest() call together, so I may as well leave it as-is.