|
2 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this file, |
3 | 3 | # You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 | # |
5 | | -# Copyright (c) 2014-2015, Lars Asplund lars.anders.asplund@gmail.com |
| 5 | +# Copyright (c) 2014-2016, Lars Asplund lars.anders.asplund@gmail.com |
6 | 6 |
|
7 | 7 | """ |
8 | 8 | The main public Python interface of VUnit. |
@@ -247,13 +247,20 @@ def disable_ieee_warnings(self): |
247 | 247 | """ |
248 | 248 | self._configuration.disable_ieee_warnings(scope=create_scope()) |
249 | 249 |
|
250 | | - def add_source_files(self, pattern, library_name, preprocessors=None, include_dirs=None): |
| 250 | + def add_source_files(self, # pylint: disable=too-many-arguments |
| 251 | + pattern, library_name, preprocessors=None, include_dirs=None, allow_empty=False): |
251 | 252 | """ |
252 | 253 | Add source files matching wildcard pattern to library |
253 | 254 | """ |
| 255 | + file_names = glob(pattern) |
| 256 | + |
| 257 | + if (not allow_empty) and len(file_names) == 0: |
| 258 | + raise ValueError(("Pattern %r did not match any file. " |
| 259 | + "Use allow_empty=True to avoid exception,") % pattern) |
| 260 | + |
254 | 261 | return FileSetFacade(source_files=[ |
255 | 262 | self.add_source_file(file_name, library_name, preprocessors, include_dirs) |
256 | | - for file_name in glob(pattern)]) |
| 263 | + for file_name in file_names]) |
257 | 264 |
|
258 | 265 | def add_source_file(self, file_name, library_name, preprocessors=None, include_dirs=None): |
259 | 266 | """ |
@@ -559,8 +566,12 @@ def disable_ieee_warnings(self): |
559 | 566 | """ |
560 | 567 | self._configuration.disable_ieee_warnings(scope=self._scope) |
561 | 568 |
|
562 | | - def add_source_files(self, pattern, preprocessors=None): |
563 | | - return self._parent.add_source_files(pattern, self._library_name, preprocessors) |
| 569 | + def add_source_files(self, pattern, preprocessors=None, allow_empty=False): |
| 570 | + return self._parent.add_source_files(pattern, self._library_name, preprocessors, |
| 571 | + allow_empty=allow_empty) |
| 572 | + |
| 573 | + def add_source_file(self, pattern, preprocessors=None): |
| 574 | + return self._parent.add_source_file(pattern, self._library_name, preprocessors) |
564 | 575 |
|
565 | 576 | def package(self, package_name): |
566 | 577 | """ |
|
0 commit comments