From patchwork Sat May 18 04:00:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1101360 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CIMrVpA5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 455Ww43Hr4z9s4Y for ; Sat, 18 May 2019 14:12:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 15631C21D56; Sat, 18 May 2019 04:06:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EF583C21DF3; Sat, 18 May 2019 04:01:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 84337C21E2C; Sat, 18 May 2019 04:01:30 +0000 (UTC) Received: from mail-it1-f193.google.com (mail-it1-f193.google.com [209.85.166.193]) by lists.denx.de (Postfix) with ESMTPS id E69B1C21DFA for ; Sat, 18 May 2019 04:01:26 +0000 (UTC) Received: by mail-it1-f193.google.com with SMTP id m141so15066845ita.3 for ; Fri, 17 May 2019 21:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KycPn3L13B77B1lpKQlhLkw71XLtcKPhetZAYHZyrqY=; b=CIMrVpA5Zrw3rpgSTVX5AiPGOP7oMjIb4HgnjHBm22p2se+YocWDW8FyjkJFCp4EvM tg5HXxuBlTUXLEI2coy5naJ55DRqTqEm0pM2YLLg34Ah/uCpqnJXqy7ZOcmVEICS45JN QbOxqVslItv7Nq0t/3CbdpgwbA+Nkjn2noipU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KycPn3L13B77B1lpKQlhLkw71XLtcKPhetZAYHZyrqY=; b=ScdKroxh+mjZQ6aJ5m16+Lmoi6xro/kVfm7pmrAH58IL0rIdMqXo2/ltun/mnb/FP2 zlw+0MWMH/ECDdLtpac+JQFNBorpjB9Tu4TXOM7tQhmzR0UaqWngG10aFmsQEjolLDh7 9MLRYPyNkoPqwSWI0sVtvl7XKE4TJx2k08nIT86VCUbqITB/+F8u0DqbLHYhkFjo9nzQ oSkMMw2P2ix9LFcdtIfYuQuWXsYfj5U4mjqrEJuC2G/J23m/kIVy+EhDrBpQs0X3x3th O+1je0yAINECyPJAGBRtO8JTQg6IKXlg0D+uM/D4fOReuQtFI1vNmMrNVKTPeg7kwGfQ jbMA== X-Gm-Message-State: APjAAAVf5dpWxYUwaQHO9P4DDIqnvTjtl3rrdKwm2ldfZzKskWnYrTxS 3vO77kFYFoyCNcBbsPefcHv21F8zJPw= X-Google-Smtp-Source: APXvYqy5UNRTsRu22q9cXyG22wqwpsSuR93bN2IVvnE1nJexARHR70kWwCBWt2+C2fl3njFEybhzOQ== X-Received: by 2002:a24:10c6:: with SMTP id 189mr5495112ity.147.1558152085773; Fri, 17 May 2019 21:01:25 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id e7sm1284986itc.44.2019.05.17.21.01.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 21:01:25 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Fri, 17 May 2019 22:00:44 -0600 Message-Id: <20190518040054.230179-15-sjg@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190518040054.230179-1-sjg@chromium.org> References: <20190518040054.230179-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Tom Rini Subject: [U-Boot] [PATCH 14/24] patman: Allow reading files in text mode X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" While reading files in binary mode is the norm, sometimes we want to use text mode. Add an optional parameter to handle this. Signed-off-by: Simon Glass --- tools/patman/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/patman/tools.py b/tools/patman/tools.py index bdc1953936c..8e9f22afe8a 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -214,7 +214,7 @@ def Filename(fname): # If not found, just return the standard, unchanged path return fname -def ReadFile(fname): +def ReadFile(fname, binary=True): """Read and return the contents of a file. Args: @@ -223,7 +223,7 @@ def ReadFile(fname): Returns: data read from file, as a string. """ - with open(Filename(fname), 'rb') as fd: + with open(Filename(fname), binary and 'rb' or 'r') as fd: data = fd.read() #self._out.Info("Read file '%s' size %d (%#0x)" % #(fname, len(data), len(data)))