Add formal handling of file pattern matching for tools.
Review Request #11531 — Created March 17, 2021 and submitted
Most tools only operate on certain file types, and all tools had to
implement their own logic for this. This meant that some were checking
if a file ends with a pattern, some were splitting file extensions, and
not all could agree on case-sensitive vs. case-insensitive matching.In an attempt to standardize this, a new
BaseTool.get_can_handle_file()
method has been added, which defaults
to checking a newBaseTool.file_patterns
for glob patterns.Comparison is case-insensitive. This is the right default behavior, but
subclasses can always overrideget_can_handle_file()
to perform their
own logic, or continue just checking directly inhandle_file()
as they
have in the past.We can extend this further down the road, if needed, to support other
entries infile_patterns
, such as compiled regex objects, to extend
capabilities in a consistent way.As of this change, no tool uses this new functionality, but changes will
be made to add support over time.
Unit tests passed.
Did some light testing with other in-progress tool work.
Summary | ID |
---|---|
885696bebf6d1c424b2a5500068c93e9ef6da7fd |
- Change Summary:
-
- Removed
settings
from this function and added**kwargs
, to prepare for an upcoming change. - Added a missing "Version Added" in the docs.
- Removed
- Commits:
-
Summary ID d3c24891bfb9ab862047d5985819a977d09e0adc 885696bebf6d1c424b2a5500068c93e9ef6da7fd