mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
dist/tools/mkconstfs: fix various flake8 issues
This commit is contained in:
parent
2a0b34d25d
commit
f124e38475
13
dist/tools/mkconstfs/mkconstfs.py
vendored
13
dist/tools/mkconstfs/mkconstfs.py
vendored
@ -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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user