diff mbox series

[OpenWrt-Devel,1/6] tools/b43-tools/b43-fwsquash: convert to Python 3 with 2-to-3

Message ID 1560802136-4157-2-git-send-email-ynezz@true.cz
State Changes Requested
Delegated to: Petr Štetiar
Headers show
Series build: switch to Python 3 | expand

Commit Message

Petr Štetiar June 17, 2019, 8:08 p.m. UTC
Let's convert the script to Python 3.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 tools/b43-tools/files/b43-fwsquash.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Yousong Zhou June 19, 2019, 11:22 a.m. UTC | #1
On Tue, 18 Jun 2019 at 04:09, Petr Štetiar <ynezz@true.cz> wrote:
>
> Let's convert the script to Python 3.
>
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> ---
>  tools/b43-tools/files/b43-fwsquash.py | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/tools/b43-tools/files/b43-fwsquash.py b/tools/b43-tools/files/b43-fwsquash.py
> index 2946d7c3c324..5d955b9d9c3e 100755
> --- a/tools/b43-tools/files/b43-fwsquash.py
> +++ b/tools/b43-tools/files/b43-fwsquash.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/env python3
>  #
>  # b43 firmware file squasher
>  # Removes unnecessary firmware files
> @@ -12,7 +12,7 @@ import sys
>  import os
>
>  def usage():
> -       print("Usage: %s PHYTYPES COREREVS /path/to/extracted/firmware" % sys.argv[0])
> +       print(("Usage: %s PHYTYPES COREREVS /path/to/extracted/firmware" % sys.argv[0]))

Was the parentheses added by script?  One pair will do

Regards,
                yousong

>         print("")
>         print("PHYTYPES is a comma separated list of:")
>         print("A         => A-PHY")
> @@ -37,17 +37,17 @@ fwpath = sys.argv[3]
>
>  phytypes = phytypes.split(',')
>  try:
> -       corerevs = map(lambda r: int(r), corerevs.split(','))
> +       corerevs = [int(r) for r in corerevs.split(',')]
>  except ValueError:
> -       print("ERROR: \"%s\" is not a valid COREREVS string\n" % corerevs)
> +       print(("ERROR: \"%s\" is not a valid COREREVS string\n" % corerevs))
>         usage()
>         sys.exit(1)
>
>
>  fwfiles = os.listdir(fwpath)
> -fwfiles = filter(lambda str: str.endswith(".fw"), fwfiles)
> +fwfiles = [str for str in fwfiles if str.endswith(".fw")]
>  if not fwfiles:
> -       print("ERROR: No firmware files found in %s" % fwpath)
> +       print(("ERROR: No firmware files found in %s" % fwpath))
>         sys.exit(1)
>
>  required_fwfiles = []
> @@ -140,10 +140,10 @@ for f in fwfiles:
>                    phytypes_match(phytypes, initvalmapping[f][1]):
>                         required_fwfiles += [f]
>                 continue
> -       print("WARNING: Firmware file %s not found in the mapping lists" % f)
> +       print(("WARNING: Firmware file %s not found in the mapping lists" % f))
>
>  for f in fwfiles:
>         if f not in required_fwfiles:
> -               print("Deleting %s" % f)
> +               print(("Deleting %s" % f))
>                 os.unlink(fwpath + '/' + f)
>
> --
> 1.9.1
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff mbox series

Patch

diff --git a/tools/b43-tools/files/b43-fwsquash.py b/tools/b43-tools/files/b43-fwsquash.py
index 2946d7c3c324..5d955b9d9c3e 100755
--- a/tools/b43-tools/files/b43-fwsquash.py
+++ b/tools/b43-tools/files/b43-fwsquash.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # b43 firmware file squasher
 # Removes unnecessary firmware files
@@ -12,7 +12,7 @@  import sys
 import os
 
 def usage():
-	print("Usage: %s PHYTYPES COREREVS /path/to/extracted/firmware" % sys.argv[0])
+	print(("Usage: %s PHYTYPES COREREVS /path/to/extracted/firmware" % sys.argv[0]))
 	print("")
 	print("PHYTYPES is a comma separated list of:")
 	print("A         => A-PHY")
@@ -37,17 +37,17 @@  fwpath = sys.argv[3]
 
 phytypes = phytypes.split(',')
 try:
-	corerevs = map(lambda r: int(r), corerevs.split(','))
+	corerevs = [int(r) for r in corerevs.split(',')]
 except ValueError:
-	print("ERROR: \"%s\" is not a valid COREREVS string\n" % corerevs)
+	print(("ERROR: \"%s\" is not a valid COREREVS string\n" % corerevs))
 	usage()
 	sys.exit(1)
 
 
 fwfiles = os.listdir(fwpath)
-fwfiles = filter(lambda str: str.endswith(".fw"), fwfiles)
+fwfiles = [str for str in fwfiles if str.endswith(".fw")]
 if not fwfiles:
-	print("ERROR: No firmware files found in %s" % fwpath)
+	print(("ERROR: No firmware files found in %s" % fwpath))
 	sys.exit(1)
 
 required_fwfiles = []
@@ -140,10 +140,10 @@  for f in fwfiles:
 		   phytypes_match(phytypes, initvalmapping[f][1]):
 			required_fwfiles += [f]
 		continue
-	print("WARNING: Firmware file %s not found in the mapping lists" % f)
+	print(("WARNING: Firmware file %s not found in the mapping lists" % f))
 
 for f in fwfiles:
 	if f not in required_fwfiles:
-		print("Deleting %s" % f)
+		print(("Deleting %s" % f))
 		os.unlink(fwpath + '/' + f)