From f124e384757d55b6b9efa23a988a01f0869c485b Mon Sep 17 00:00:00 2001 From: Alexandre Abadie <alexandre.abadie@inria.fr> Date: Wed, 20 Dec 2017 16:48:56 +0100 Subject: [PATCH] dist/tools/mkconstfs: fix various flake8 issues --- dist/tools/mkconstfs/mkconstfs.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dist/tools/mkconstfs/mkconstfs.py b/dist/tools/mkconstfs/mkconstfs.py index bda89c76d8..1b56492546 100755 --- a/dist/tools/mkconstfs/mkconstfs.py +++ b/dist/tools/mkconstfs/mkconstfs.py @@ -5,6 +5,8 @@ import os import sys FILE_TYPE = "static const uint8_t" +FILES = [] + def mkconstfs(root_path, mount_point, constfs_name): print("/* This file was automatically generated by mkconstfs */") @@ -20,7 +22,7 @@ def mkconstfs(root_path, mount_point, constfs_name): print("\nstatic const constfs_file_t _files[] = {") - for mangled_name, target_name, _ in files: + for mangled_name, target_name, _ in FILES: print(" {") print(" .path = \"%s\"," % target_name) print(" .data = %s," % mangled_name) @@ -41,12 +43,14 @@ vfs_mount_t %s = { }; """ % (constfs_name, mount_point)) + def mangle_name(fname): fname = fname.replace("/", "__") fname = fname.replace(".", "__") return fname + def print_file_data(local_fname, target_fname): mangled_name = mangle_name(target_fname) print(FILE_TYPE, mangled_name, "[] = {", end="") @@ -63,17 +67,16 @@ def print_file_data(local_fname, target_fname): else: print(", ", end="") nread += 1 - print ("0x" + codecs.encode(byte, 'hex').decode('ascii'), end="") + print("0x" + codecs.encode(byte, 'hex').decode('ascii'), end="") # Do stuff with byte. byte = f.read(1) print("\n};") - files.append((mangled_name, target_fname, nread)) + FILES.append((mangled_name, target_fname, nread)) -files = [] -if __name__=="__main__": +if __name__ == "__main__": mountpoint = "/" constfs_name = "_constfs" -- GitLab