Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Olof Johansson <olof.johansson@axis.com>
To: openembedded-core@lists.openembedded.org
Cc: Olof Johansson <olofjn@axis.com>
Subject: [PATCH 3/4] spdx.bbclass: Make use of bb.utils' sha1_file()
Date: Mon, 16 Jul 2018 17:05:55 +0200	[thread overview]
Message-ID: <20180716150556.16415-4-olofjn@axis.com> (raw)
In-Reply-To: <20180716150556.16415-1-olofjn@axis.com>

The same functionality already exists within bitbake, so avoid
duplicating.

Signed-off-by: Olof Johansson <olofjn@axis.com>
---
 meta/classes/spdx.bbclass | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/meta/classes/spdx.bbclass b/meta/classes/spdx.bbclass
index 9e374d70a6c..a3e22afc33d 100644
--- a/meta/classes/spdx.bbclass
+++ b/meta/classes/spdx.bbclass
@@ -202,13 +202,8 @@ def list_files(dir):
     return
 
 def hash_file(file_name):
-    try:
-        with open(file_name, 'rb') as f:
-            data_string = f.read()
-            sha1 = hash_string(data_string)
-            return sha1
-    except:
-        return None
+    from bb.utils import sha1_file
+    return sha1_file(file_name)
 
 def hash_string(data):
     import hashlib
-- 
2.11.0



  parent reply	other threads:[~2018-07-16 15:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 15:05 [PATCH 0/4] Small spdx.bbclass fixes Olof Johansson
2018-07-16 15:05 ` [PATCH 1/4] spdx.bbclass: Replace deprecated string.replace with str.replace Olof Johansson
2018-07-16 15:05 ` [PATCH 2/4] spdx.bbclass: Fix undefined variable error Olof Johansson
2018-07-16 15:05 ` Olof Johansson [this message]
2018-07-16 15:05 ` [PATCH 4/4] spdx.bbclass: Encode strings before passing to hashlib Olof Johansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180716150556.16415-4-olofjn@axis.com \
    --to=olof.johansson@axis.com \
    --cc=olofjn@axis.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox