diff
¶
Module Contents¶
Functions¶
|
Compute diff between two files or list of strings. |
|
Apply a patch, ignoring changes in files matching discarded_files. |
Attributes¶
- diff.logger¶
- exception diff.DiffError(message: str | list[str], origin: str | None = None)¶
Bases:
e3.error.E3Error
Error returned when the patch command fails.
- exception diff.EmptyDiffError(message: str | list[str], origin: str | None = None)¶
Bases:
DiffError
Error returned when the patch is empty.
These situation can occur when all the patched files are discarded.
- diff.diff(a: str | list[str], b: str | list[str], ignore: str | None = None, item1name: str = 'expected', item2name: str = 'output', ignore_white_chars: bool = True, context: int = 1) str ¶
Compute diff between two files or list of strings.
- Parameters:
a – a filename or a list of strings
b – a filename or a list of strings
ignore – all lines matching this pattern in both files are ignored during comparison. If set to None, all lines are considered.
item1name – name to display for a in the diff
item2name – name to display for b in the diff
ignore_white_chars – if True (default) then empty lines, trailing and leading white chars on each line are ignored
context – positive number of context lines to add to the diff
- Returns:
A diff string. If the string is equal to ‘’ it means that there is no difference
- diff.patch(patch_file: str, working_dir: str, discarded_files: list[str] | collections.abc.Callable[[str], bool] | None = None, filtered_patch: str | None = None) None ¶
Apply a patch, ignoring changes in files matching discarded_files.
- Parameters:
patch_file – the file containing the patch to apply
working_dir – the directory where to apply the patch
discarded_files – list of files or glob patterns (or function taking a filename and returning a boolean - True if the file should be discarded)
filtered_patch – name of the filtered patch. By default append ‘.filtered’ to the patch_file name