diff --git a/src/ibunfuck.py b/src/ibunfuck.py index e1ea7fd..5cbf651 100644 --- a/src/ibunfuck.py +++ b/src/ibunfuck.py @@ -28,11 +28,12 @@ def __init__(self, path): def _clear_patch(self, patch, processors): has_changes = False for i, patch_piece in enumerate(patch): + length = len(patch_piece) for j, hunk in enumerate(patch_piece[::-1]): if not all(p(hunk) for p in processors): continue - del patch[i][len(patch_piece) - j - 1] + del patch[i][length - j - 1] has_changes = has_changes or len(patch[i]) > 0 diff --git a/src/plugins.py b/src/plugins.py index 0f039f2..f94c26f 100644 --- a/src/plugins.py +++ b/src/plugins.py @@ -23,8 +23,14 @@ def _xml_changes(klass, chunk): @classmethod def _is_valid_dimension(klass, hunk, tag, properties): minus, plus = klass._xml_changes(hunk) + if any(x.tag != tag for x in minus + plus): + return True + if len(minus) == 1 and len(plus) == 1: mnode, pnode = minus[0], plus[0] + if mnode.tag != pnode.tag or mnode.tag != tag or pnode.tag != tag: + return True + is_right_tag = mnode.tag == pnode.tag == tag diffs = [abs(float(mnode.attrib[p]) - float(pnode.attrib[p])) for p in properties]