From: Mateusz Majewski Date: Wed, 27 Sep 2023 08:56:37 +0000 (+0200) Subject: :) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fsandbox%2Fmmajewski2%2Fsd_fusing_py_lint;p=platform%2Fkernel%2Fu-boot.git :) --- diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index 78a8997ae5..e6d2eb7cb5 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -55,7 +55,7 @@ class Partition: output = [] if self.start: output.append(f"start={self.start}MiB") - if type(self.size) == int and self.size >= 0: + if isinstance(self.size, int) and self.size >= 0: output.append(f"size={self.size}MiB") if self.name: output.append(f"name={self.name}") @@ -114,7 +114,7 @@ class RpiInitParams: n = None for i, p in enumerate(self.part_table): if p['name'] == 'inform': - n = i + 1; + n = i + 1 d = "/dev/" + get_partition_device(self.device, n) subprocess.run(['tune2fs', '-O', '^metadata_csum', d], @@ -350,7 +350,7 @@ def check_sfdisk(): support_delete = False if major < 2 or major == 2 and minor < 26: - log.error(f"Your sfdisk {major}.{minor}.{patch} is too old.") + logging.error(f"Your sfdisk {major}.{minor}.{patch} is too old.") return False,False elif major == 2 and minor >= 28: support_delete = True @@ -381,12 +381,12 @@ def mkpart(args, target): input=str(target.label).encode()) if proc.returncode != 0: logging.error(f"Failed to create partition a new table on {Device}") - logging.error(f"New partition table:\n" + str(target.label)) + logging.error("New partition table:\n" + str(target.label)) sys.exit(1) for i, part in enumerate(target.part_table): d = "/dev/" + get_partition_device(target.device, i+1) - if not 'fstype' in part: + if 'fstype' not in part: logging.debug(f"Filesystem not defined for {d}, skipping") continue logging.debug(f"Formatting {d} as {part['fstype']}") @@ -395,14 +395,14 @@ def mkpart(args, target): stdin=subprocess.DEVNULL, stdout=None, stderr=None) if proc.returncode != 0: - log.error(f"Failed to create FAT filesystem on {d}") + logging.error(f"Failed to create FAT filesystem on {d}") sys.exit(1) elif part['fstype'] == 'ext4': proc = subprocess.run(['mkfs.ext4', '-q', '-L', part['name'], d], stdin=subprocess.DEVNULL, stdout=None, stderr=None) if proc.returncode != 0: - log.error(f"Failed to create ext4 filesystem on {d}") + logging.error(f"Failed to create ext4 filesystem on {d}") sys.exit(1) elif part['fstype'] == 'raw': pass @@ -496,7 +496,7 @@ def get_partition_device(device, idx): proc = subprocess.run(['lsblk', device, '-o', 'TYPE,KNAME'], stdout=subprocess.PIPE) for l in proc.stdout.decode('utf-8').splitlines(): - match = re.search(f"^part\s+(.*[^0-9]{idx})", l) + match = re.search(f"^part\\s+(.*[^0-9]{idx})", l) if match: return match[1] return None @@ -594,7 +594,7 @@ def fuse_image(args, target): return with tempfile.TemporaryDirectory() as tmpd: for b in args.binaries: - if re.search('\.(tar|tar\.gz|tgz)$', b): + if re.search('\\.(tar|tar\\.gz|tgz)$', b): do_fuse_image_tarball(b, tmpd, target) else: fn = os.path.split(b)[-1] @@ -608,7 +608,7 @@ def fuse_image(args, target): if __name__ == '__main__': parser = argparse.ArgumentParser(description="For {}, version {}".format( - ", ".join([v.long_name for k,v in TARGETS.items()]), + ", ".join([v.long_name for _, v in TARGETS.items()]), __version__ )) parser.add_argument("-b", "--binary", action="append", dest="binaries",