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 |
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 --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)
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(-)