polib icon indicating copy to clipboard operation
polib copied to clipboard

Allow more control comparing PO entries

Open mondeja opened this issue 3 years ago • 0 comments

I've a case in which I'm comparing PO entries without take into account msgstr neither obsolete. Currently, I'm duplicating the POEntry.__cmp__ function adding optional parameters compare_obsolete and compare_msgstr. Could this be added to polib, maybe adding other parameters for msgstr_plural, msgid...?


class Foo:
    def __cmp__(self, other, are_equal=False, other_are_equal=False):
        if are_equal or other_are_equal:
            return True
        return False

a = Foo()
b = Foo()

print(a == b)                                                  # False
print(a != b)                                                  # True
print(a.__cmp__(b))                                            # False
print(a.__cmp__(b, are_equal=False, other_are_equal=True))     # True
print(a.__cmp__(b, are_equal=True, other_are_equal=False))     # True

mondeja avatar May 01 '21 21:05 mondeja