DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH v2 4/6] dpdk-devbind: do not use len(x) to test for empty
Date: Tue,  3 Nov 2020 23:03:48 -0800
Message-ID: <20201104070350.28224-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20201104070350.28224-1-stephen@networkplumber.org>

Python lint warns about using len(SEQUENCE) to determine if sequence is empty.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 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 <name>_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("<none>")
     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


  parent reply	other threads:[~2020-11-04  7:05 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-06  1:31 [dpdk-dev] [PATCH 00/11] Python script updates Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 01/11] cpu_layout: refactor to meet python standards Stephen Hemminger
2020-11-04  6:53   ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
2020-11-04  9:21     ` Bruce Richardson
2020-11-04 16:22       ` Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 02/11] dpdk-pmdinfo: replace string.split with split Stephen Hemminger
2020-11-04  6:48   ` [dpdk-dev] [PATCH v2 0/7] dpdk-pmdinfo: python lint cleanups Stephen Hemminger
2020-11-04  6:48     ` [dpdk-dev] [PATCH v2 1/7] dpdk-pmdinfo: replace string.split with split Stephen Hemminger
2020-11-04  6:48     ` [dpdk-dev] [PATCH v2 2/7] dpdk-pmdinfo: replace io.open with open Stephen Hemminger
2020-11-04  6:48     ` [dpdk-dev] [PATCH v2 3/7] dpdk-pmdinfo: remove unnecessary paren and else Stephen Hemminger
2020-11-04  6:48     ` [dpdk-dev] [PATCH v2 4/7] dpdk-pmdinfo: replace is False and is True Stephen Hemminger
2020-11-04  6:48     ` [dpdk-dev] [PATCH v2 5/7] dpdk-pmdinfo: fix indentation Stephen Hemminger
2020-11-04  6:48     ` [dpdk-dev] [PATCH v2 6/7] dpdk-pmdinfo: replace deprecated optparse with argparse Stephen Hemminger
2020-11-24  6:35       ` Jiang, YuX
2020-11-04  6:48     ` [dpdk-dev] [PATCH v2 7/7] dpdk-pmdinfo: do not use len(x) to test for empty Stephen Hemminger
2020-11-22 20:54     ` [dpdk-dev] [PATCH v2 0/7] dpdk-pmdinfo: python lint cleanups Thomas Monjalon
2020-09-06  1:31 ` [dpdk-dev] [PATCH 03/11] dpdk-pmdinfo: replace io.open with open Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 04/11] dpdk-pmdinfo: remove dead code Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 05/11] dpdk-pmdinfo: remove unnecessary paren and else Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 06/11] dpdk-pmdinfo: replace is False and is True Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 07/11] dpdk-pmdinfo: fix indentation Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 08/11] dpdk-pmdinfo: replace deprecated optparse with argparse Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 09/11] dpdk-pmdinfo: do not use len(x) to test for empty Stephen Hemminger
2020-09-07  9:03   ` Bruce Richardson
2020-09-07 17:20     ` Stephen Hemminger
2020-09-06  1:31 ` [dpdk-dev] [PATCH 10/11] dpdk-telemetry-client: fix some pylint warnings Stephen Hemminger
2020-09-07  9:05   ` Bruce Richardson
2020-11-04  7:00   ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
2020-11-15 23:06     ` Thomas Monjalon
2020-09-06  1:31 ` [dpdk-dev] [PATCH 11/11] dpdk-devbind: use argparse instead of getopt Stephen Hemminger
2020-11-04  7:03   ` [dpdk-dev] [PATCH v2 0/6] dpdk-devbind: python lint cleanups Stephen Hemminger
2020-11-04  7:03     ` [dpdk-dev] [PATCH v2 1/6] dpdk-devbind: use argparse instead of getopt Stephen Hemminger
2020-11-04  7:03     ` [dpdk-dev] [PATCH v2 2/6] dpdk-devbind: fix indentation Stephen Hemminger
2020-11-04  7:03     ` [dpdk-dev] [PATCH v2 3/6] dpdk-devbind: fix python lint warnings for imports Stephen Hemminger
2020-11-04  7:03     ` Stephen Hemminger [this message]
2020-11-04  7:03     ` [dpdk-dev] [PATCH v2 5/6] dpdk-devbind: fix unnecessary else after return Stephen Hemminger
2020-11-04  7:03     ` [dpdk-dev] [PATCH v2 6/6] dpdk-devbind: use in to test for multiple strings Stephen Hemminger
2020-11-04  9:28     ` [dpdk-dev] [PATCH v2 0/6] dpdk-devbind: python lint cleanups Bruce Richardson
2020-11-22 21:03       ` Thomas Monjalon
2020-11-04 16:57     ` Stephen Hemminger

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=20201104070350.28224-5-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git