From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 97D6DA04E7; Wed, 4 Nov 2020 08:05:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1021AC820; Wed, 4 Nov 2020 08:04:04 +0100 (CET) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by dpdk.org (Postfix) with ESMTP id 6375BC800 for ; Wed, 4 Nov 2020 08:04:00 +0100 (CET) Received: by mail-pl1-f181.google.com with SMTP id p4so2520155plr.1 for ; Tue, 03 Nov 2020 23:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HVmy6jIyBJ3FxEhLvU+pl0hzRKROkGn/d3GPRV8rMps=; b=RBYmDP44cfeKkhwst0B+dFIuDh+OwCQIybFt1PKEs6XuaHIfIq/zBNBTiLhiUz6Xbf 9OWhkn0fCwxRK9BMBGho31zGuDyxCUdkLsEPMb/i7em/Ey/b/QVP8c/37nm+y4V161fH +/z/Wy6bGKXhko+v+cZoCs4z2uLUk1L9/t3aSlA0ZTAAcPC11BMj+aXafWtnXawpqbsQ zHKotGus1d5oD2KnIhKPYjuy6R7iC2NTOJal2eJnXyT3b2PNbKIQrdHCIyv1tmZ5YHno 05MfTFc+R4DAKtFGGlPglFnCsnVzZyLBNaeDhTEwR6EKwoerm0uUjVaFLXNTpUf8Okcv b79g== 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=HVmy6jIyBJ3FxEhLvU+pl0hzRKROkGn/d3GPRV8rMps=; b=bT4DSrqvMLJxnDqPubBfpaMqge+ZPwxfjI7XvAbMaq956COZeTGrEo9hag6XgvaXhq PO7/TndQO4GpUSkh2gia5M9FYMoFAU0SuLv/rMJVnBaLp7Ss3YvdMujnorq+xuSuIR/1 CC32eB53g9FlEYpJd2bK3TrnnWe47HoEKq+9XrtHRy8u+kNtt3EacHef6MtCCebNEwN/ snl7kcDchJQZGgG3cA7gHpjeDAw0+ERUx9hgnw2b0gS7A+ngwK4RSrxgvv/06xltvXC4 8Op7mgOSInMC3uBz8sFmD5uWw4Ip2+AYKYSEFKsfRWOXZQRTxd4udr7F/DazpchwRsVM iy8g== X-Gm-Message-State: AOAM531BSnJVatkmYfkzOwEzavt83qvxk2YgqvFyvh91K5t/e9PXQX1g /17sCoFwyv3qQ1xF05K4FJnZSF/X6lm0HlN5 X-Google-Smtp-Source: ABdhPJyGXOWSoKHRStYeH2Lyv2SKf8wgV5sv5w93OlUblzsxkHfeCSJFkIKz9t2hkMiXmMNeOkVGrQ== X-Received: by 2002:a17:902:82c3:b029:d6:c377:c87d with SMTP id u3-20020a17090282c3b02900d6c377c87dmr14917077plz.37.1604473438098; Tue, 03 Nov 2020 23:03:58 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z21sm1181177pfa.158.2020.11.03.23.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 23:03:57 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 3 Nov 2020 23:03:48 -0800 Message-Id: <20201104070350.28224-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104070350.28224-1-stephen@networkplumber.org> References: <20200906013133.26360-12-stephen@networkplumber.org> <20201104070350.28224-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 4/6] dpdk-devbind: do not use len(x) to test for empty X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Python lint warns about using len(SEQUENCE) to determine if sequence is empty. Signed-off-by: Stephen Hemminger --- usertools/dpdk-devbind.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 4148b66b6841..afe93a217d79 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -143,7 +143,7 @@ def get_pci_device_details(dev_id, probe_lspci): extra_info = subprocess.check_output(["lspci", "-vmmks", dev_id]).splitlines() # parse lspci details for line in extra_info: - if len(line) == 0: + if not line: continue name, value = line.decode("utf8").split("\t", 1) name = name.strip(":") + "_str" @@ -178,7 +178,7 @@ def get_device_details(devices_type): dev = {} dev_lines = subprocess.check_output(["lspci", "-Dvmmnnk"]).splitlines() for dev_line in dev_lines: - if len(dev_line) == 0: + if not dev_line: if device_type_match(dev, devices_type): # Replace "Driver" with "Driver_str" to have consistency of # of dictionary key names @@ -193,7 +193,7 @@ def get_device_details(devices_type): else: name, value = dev_line.decode("utf8").split("\t", 1) value_list = value.rsplit(' ', 1) - if len(value_list) > 1: + if value_list: # String stored in _str dev[name.rstrip(":") + '_str'] = value_list[0] # Numeric IDs @@ -496,7 +496,7 @@ def display_devices(title, dev_list, extra_params=None): strings = [] # this holds the strings to print. We sort before printing print("\n%s" % title) print("="*len(title)) - if len(dev_list) == 0: + if not dev_list: strings.append("") else: for dev in dev_list: @@ -539,17 +539,17 @@ def show_device_status(devices_type, device_name, if_field=False): return # print each category separately, so we can clearly see what's used by DPDK - if len(dpdk_drv) != 0: + if dpdk_drv: display_devices("%s devices using DPDK-compatible driver" % device_name, dpdk_drv, "drv=%(Driver_str)s unused=%(Module_str)s") - if len(kernel_drv) != 0: + if kernel_drv: if_text = "" if if_field: if_text = "if=%(Interface)s " display_devices("%s devices using kernel driver" % device_name, kernel_drv, if_text + "drv=%(Driver_str)s " "unused=%(Module_str)s %(Active)s") - if len(no_drv) != 0: + if no_drv: display_devices("Other %s devices" % device_name, no_drv, "unused=%(Module_str)s") -- 2.27.0