Improve validation messages #196
@ -172,13 +172,21 @@ def find_forbidden_filepaths(file_list):
|
||||
def validate_file_list(toml_content, manifest_filepath, file_list):
|
||||
"""Check the files in in the archive against manifest."""
|
||||
error_codes = []
|
||||
type_slug = toml_content['type']
|
||||
found_forbidden_filepaths = find_forbidden_filepaths(file_list)
|
||||
|
||||
# Special treatment for Mac, so the same problem (__MACOSX folders) doesn't lead to two errors showing.
|
||||
if type_slug == 'theme' and '__MACOSX/' not in found_forbidden_filepaths:
|
||||
found_forbidden_filepaths = find_forbidden_filepaths(file_list)
|
||||
if found_forbidden_filepaths:
|
||||
error_codes.append(
|
||||
{
|
||||
dfelinto marked this conversation as resolved
Outdated
|
||||
'code': 'forbidden_filepaths',
|
||||
'params': {'paths': ', '.join(found_forbidden_filepaths)},
|
||||
}
|
||||
)
|
||||
type_slug = toml_content['type']
|
||||
if type_slug == 'theme':
|
||||
theme_xmls = filter_paths_by_ext(file_list, '.xml')
|
||||
if len(list(theme_xmls)) != 1:
|
||||
# Special treatment for Mac, so the same problem (__MACOSX folders)
|
||||
# doesn't lead to two errors showing.
|
||||
if len(list(theme_xmls)) != 1 and '__MACOSX/' not in found_forbidden_filepaths:
|
||||
error_codes.append('missing_or_multiple_theme_xml')
|
||||
elif type_slug == 'add-on':
|
||||
# __init__.py is expected to be next to the manifest
|
||||
@ -195,13 +203,6 @@ def validate_file_list(toml_content, manifest_filepath, file_list):
|
||||
error_codes.append(
|
||||
{'code': 'missing_wheel', 'params': {'path': expected_wheel_path}}
|
||||
)
|
||||
if found_forbidden_filepaths:
|
||||
error_codes.append(
|
||||
{
|
||||
'code': 'forbidden_filepaths',
|
||||
'params': {'paths': ', '.join(found_forbidden_filepaths)},
|
||||
}
|
||||
)
|
||||
return error_codes
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
let's restructure this check a bit to prevent possible confusion in the future:
i.e. let's move the
and '__MACOSX/' not in found_forbidden_filepaths
part to theif len(list(theme_xmls)) != 1
lineand it's better to move the
found_forbidden_filepaths
logic closer to the variable declaration - i.e. let's move the whole block up, not just the variable declaration