def compare(self, old: str, old_date: str, new: str, new_date: str,
ctx: common.Context, meta: dict) \
-> ty.Tuple[bool, ty.Optional[str], ty.Optional[dict]]:
# pylint: disable=invalid-sequence-index
old = old.replace(common.RECORD_SEPARATOR, '\n\n')
new = new.replace(common.RECORD_SEPARATOR, '\n\n')
old_lines = old.split('\n')
res = list(difflib.ndiff(old_lines, new.split('\n')))
changed_lines = sum(1 for line in res if line and line[0] != ' ')
if not _check_changes(ctx, changed_lines, len(old_lines),
self.conf.get("changes_threshold"),
self.conf.get("min_changed")):
return False, None, None
return True, "\n".join(res), self.opts
评论列表
文章目录