Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions finalize_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
import tomli
import tomli_w

class ManifestError(Exception):
"""Thrown at errors in manifest parsing and handling.

Contains a string with error description.
"""

def is_utf8(filename_bytes):
try:
filename_bytes.decode('UTF-8')
Expand All @@ -40,9 +46,13 @@ def expand_trusted_files(trusted_files):
for uri in trusted_files:
file_path = uri2path(uri)
if file_path.exists():
expanded_files.append({'uri': uri, 'sha256': compute_sha256(file_path)})
else:
raise ManifestError(f'File not found: {file_path}')
if file_path.is_dir():
for root, _, files in os.walk(file_path):
for file in files:
full_path = pathlib.Path(root) / file
expanded_files.append({'uri': f'file:{full_path}', 'sha256': compute_sha256(full_path)})
else:
expanded_files.append({'uri': uri, 'sha256': compute_sha256(file_path)})
return expanded_files

def extract_files_from_user_manifest(manifest):
Expand Down