Project

General

Profile

« Previous | Next » 

Revision 98687e91

Added by koszko over 1 year ago

raise a more informative error when a file referenced from index.json is missing

View differences:

src/hydrilla/builder/build.py
212 212

  
213 213
        file_ref = self.files_by_path.get(desired_path)
214 214
        if file_ref is None:
215
            with open(path, 'rb') as file_handle:
216
                contents = file_handle.read()
215
            if not path.is_file():
216
                msg = _('referenced_file_{}_missing').format(desired_path)
217
                raise FileReferenceError(msg)
217 218

  
218
            file_ref = FileRef(desired_path, contents)
219
            file_ref = FileRef(desired_path, path.read_bytes())
219 220
            self.files_by_path[desired_path] = file_ref
220 221

  
221 222
        if include_in_distribution:
src/hydrilla/builder/locales/en_US/LC_MESSAGES/hydrilla-messages.po
7 7
msgstr ""
8 8
"Project-Id-Version: hydrilla.builder 0.1.dev16+g4e46d7f.d20220211\n"
9 9
"Report-Msgid-Bugs-To: koszko@koszko.org\n"
10
"POT-Creation-Date: 2022-05-10 16:47+0200\n"
10
"POT-Creation-Date: 2022-05-11 11:10+0200\n"
11 11
"PO-Revision-Date: 2022-02-12 00:00+0000\n"
12 12
"Last-Translator: Wojtek Kosior <koszko@koszko.org>\n"
13 13
"Language: en_US\n"
......
18 18
"Content-Transfer-Encoding: 8bit\n"
19 19
"Generated-By: Babel 2.8.0\n"
20 20

  
21
#: src/hydrilla/builder/build.py:86 src/hydrilla/builder/local_apt.py:117
22
#: src/hydrilla/builder/local_apt.py:408
21
#: src/hydrilla/builder/build.py:86 src/hydrilla/builder/local_apt.py:118
22
#: src/hydrilla/builder/local_apt.py:407
23 23
msgid "couldnt_execute_{}_is_it_installed"
24 24
msgstr "Could not execute '{}'. Is the tool installed and reachable via PATH?"
25 25

  
26
#: src/hydrilla/builder/build.py:90 src/hydrilla/builder/local_apt.py:121
27
#: src/hydrilla/builder/local_apt.py:412
26
#: src/hydrilla/builder/build.py:90 src/hydrilla/builder/local_apt.py:122
27
#: src/hydrilla/builder/local_apt.py:411
28 28
msgid "command_{}_failed"
29 29
msgstr "The following command finished execution with a non-zero exit status: {}"
30 30

  
......
42 42
msgid "loading_reserved_index_json"
43 43
msgstr "Attempt to load 'index.json' which is a reserved filename."
44 44

  
45
#: src/hydrilla/builder/build.py:350
45
#: src/hydrilla/builder/build.py:216
46
msgid "referenced_file_{}_missing"
47
msgstr "Referenced file '{}' is missing."
48

  
49
#: src/hydrilla/builder/build.py:351
46 50
msgid "report_spdx_not_in_copyright_list"
47 51
msgstr ""
48 52
"Told to generate 'report.spdx' but 'report.spdx' is not listed among "
49 53
"copyright files. Refusing to proceed."
50 54

  
51
#: src/hydrilla/builder/build.py:421
55
#: src/hydrilla/builder/build.py:422
52 56
msgid "build_package_from_srcdir_to_dstdir"
53 57
msgstr ""
54 58
"Build Hydrilla package from `scrdir` and write the resulting files under "
55 59
"`dstdir`."
56 60

  
57
#: src/hydrilla/builder/build.py:423
61
#: src/hydrilla/builder/build.py:424
58 62
msgid "source_directory_to_build_from"
59 63
msgstr "Source directory to build from."
60 64

  
61
#: src/hydrilla/builder/build.py:425
65
#: src/hydrilla/builder/build.py:426
62 66
msgid "path_instead_of_index_json"
63 67
msgstr ""
64 68
"Path to file to be processed instead of index.json (if not absolute, "
65 69
"resolved relative to srcdir)."
66 70

  
67
#: src/hydrilla/builder/build.py:427
71
#: src/hydrilla/builder/build.py:428
68 72
msgid "path_instead_for_piggyback_files"
69 73
msgstr ""
70 74
"Path to a non-standard directory with foreign packages' archive files to "
71 75
"use."
72 76

  
73
#: src/hydrilla/builder/build.py:429
77
#: src/hydrilla/builder/build.py:430
74 78
msgid "built_package_files_destination"
75 79
msgstr "Destination directory to write built package files to."
76 80

  
77
#: src/hydrilla/builder/build.py:431
81
#: src/hydrilla/builder/build.py:432
78 82
#, python-format
79 83
msgid "%(prog)s_%(version)s_license"
80 84
msgstr ""
......
85 89
"This is free software: you are free to change and redistribute it.\n"
86 90
"There is NO WARRANTY, to the extent permitted by law."
87 91

  
88
#: src/hydrilla/builder/build.py:432
92
#: src/hydrilla/builder/build.py:433
89 93
msgid "version_printing"
90 94
msgstr "Print version information and exit."
91 95

  
......
97 101
msgid "STDERR_OUTPUT_heading"
98 102
msgstr "## Command's standard error output ##"
99 103

  
100
#: src/hydrilla/builder/local_apt.py:146
104
#: src/hydrilla/builder/local_apt.py:147
101 105
msgid "distro_{}_unknown"
102 106
msgstr "Attempt to use an unknown software distribution '{}'."
103 107

  
104
#: src/hydrilla/builder/local_apt.py:189
108
#: src/hydrilla/builder/local_apt.py:190
105 109
msgid "couldnt_import_{}_is_it_installed"
106 110
msgstr ""
107 111
"Could not import '{}'. Is the module installed and visible to this Python"
108 112
" instance?"
109 113

  
110
#: src/hydrilla/builder/local_apt.py:197
114
#: src/hydrilla/builder/local_apt.py:198
111 115
msgid "gpg_couldnt_recv_key_{}"
112 116
msgstr "Could not import PGP key '{}'."
113 117

  
114
#: src/hydrilla/builder/local_apt.py:314
118
#: src/hydrilla/builder/local_apt.py:312
115 119
msgid "apt_install_output_not_understood"
116 120
msgstr "The output of an 'apt-get install' command was not understood."
117 121

  
118
#: src/hydrilla/builder/local_apt.py:342
122
#: src/hydrilla/builder/local_apt.py:338
119 123
msgid "apt_download_gave_bad_filename_{}"
120 124
msgstr "The 'apt-get download' command produced a file with unexpected name '{}'."
121 125

  
tests/test_build.py
582 582
    Modify index.json to expect missing report.spdx file and cause an error.
583 583
    """
584 584
    monkeypatch.delitem(index_obj, 'reuse_generate_spdx_report')
585
    return FileNotFoundError,
585
    return FileReferenceError, '^referenced_file_report.spdx_missing$'
586 586

  
587 587
@error_maker
588 588
def sample_source_error_index_schema(monkeypatch, sample_source):

Also available in: Unified diff