# HG changeset patch # User Paul Boddie # Date 1512948757 -3600 # Node ID 829ed36c32d67039a6d6544c95c8c8c1f5cd831d # Parent 337a05845a69789c02903fdb16a60da1261f3c80 Added copying and comparison support to selectors. diff -r 337a05845a69 -r 829ed36c32d6 vRecurrence.py --- a/vRecurrence.py Sun Dec 10 23:41:21 2017 +0100 +++ b/vRecurrence.py Mon Dec 11 00:32:37 2017 +0100 @@ -950,6 +950,17 @@ def set_values(self, values): self.args["values"] = values + # Copying and comparison support. + + def as_tuple(self): + return self.level, self.args, self.qualifier, self.selecting + + def copy(self): + return self.__class__(*self.as_tuple()) + + def __cmp__(self, other): + return cmp(self.as_tuple(), other and other.as_tuple()) + class Pattern(Selector): "A selector of time periods according to a repeating pattern." @@ -1003,6 +1014,11 @@ self.args["interval"] = interval self.update_step() + # Copying and comparison support. + + def as_tuple(self): + return self.level, self.args, self.qualifier, self.selecting, self.first + class Enum(Selector): "A generic value selector."