Skip to content
Snippets Groups Projects
Commit f124e384 authored by Alexandre Abadie's avatar Alexandre Abadie
Browse files

dist/tools/mkconstfs: fix various flake8 issues

parent 2a0b34d2
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment