A blank line (or even a new line at the end) in a manifest file causes an error in pathlib.Path.glob():
Traceback (most recent call last):
File "/home/scripsi/project/build/dir2uf2/dir2uf2", line 190, in <module>
copy_manifest_or_dir(lfs, args.source_dir)
File "/home/scripsi/project/build/dir2uf2/dir2uf2", line 187, in copy_manifest_or_dir
copy_files(lfs, source_dir.glob(item), source_dir)
File "/home/scripsi/project/build/dir2uf2/dir2uf2", line 154, in copy_files
for src in todo:
File "/usr/lib/python3.12/pathlib.py", line 1089, in glob
raise ValueError("Unacceptable pattern: {!r}".format(pattern))
ValueError: Unacceptable pattern: ''
Solution
Test for a non-blank item in the todo list in copy_manifest_or_dir() before passing it to the copy_files() call:
def copy_manifest_or_dir(lfs, source_dir):
if args.manifest is None:
print(f"Copying directory: {source_dir}")
# Walk the entire source dir and copy *everything*
search_path = os.path.join("**", "*")
copy_files(lfs, source_dir.glob(search_path), source_dir)
else:
print(f"Using manifest: {args.manifest}")
# Copy files/globs listed in the manifest relative to the source dir
todo = open(args.manifest, "r").read().split("\n")
for item in todo:
if item: # <<< test for non-blank item here!
parent_dir = pathlib.Path(item).parent
lfs.makedirs(str(parent_dir), exist_ok=True)
copy_files(lfs, source_dir.glob(item), source_dir)
Issue
A blank line (or even a new line at the end) in a manifest file causes an error in pathlib.Path.glob():
Solution
Test for a non-blank
item
in thetodo
list incopy_manifest_or_dir()
before passing it to thecopy_files()
call:System on which error occurred: