mbedignore.py from https://github.com/KKoovalsky/PlatformIO-Helpers/commit/47c9947bf0fe5e730591eb9223c73fe6f193c80b#diff-9e3f883d61ad218eb1e4b0952376bbb70303f58a23d17d4fa81f457518fced55
"""
importos.path
importsys
frompathlibimportPath
fromshutilimportcopyfile
def_eprint(*args,**kwargs):
""" Prints to stderr """
print(*args,file=sys.stderr,**kwargs)
def_lines_to_list(path):
"""
Reads file from at the specified path and creates a list which contains
lines from the file, without a newline.
"""
withopen(path,'r')asf:
returnf.read().splitlines()
def_is_ignored(path):
"""
Checks whether the specified path is ignored within the Mbed compilation.
In details, takes the .mbedignore file in the path and checks whether it
contains a line with string '*'.
"""
mbedignore_path=os.path.join(path,'.mbedignore')
ifnotPath(mbedignore_path).is_file():
returnFalse
withopen(mbedignore_path)asf:
lines=f.read().splitlines()
return'*'inlines
def_is_extra_newline_necessary(file):
"""
Returns True if in the specific file, at the specified path (parameter
file is a path to the file) an extra newline shall be added when writing
a line to it. Sometimes there is no newline at the end of the file