vContent

Changeset

101:1faaf5e25d5e
2017-12-11 Paul Boddie raw files shortlog changelog graph Added copying and comparison support to selectors. default tip
vRecurrence.py (file)
     1.1 --- a/vRecurrence.py	Sat Dec 09 22:35:53 2017 +0100
     1.2 +++ b/vRecurrence.py	Mon Dec 11 00:32:37 2017 +0100
     1.3 @@ -950,6 +950,17 @@
     1.4      def set_values(self, values):
     1.5          self.args["values"] = values
     1.6  
     1.7 +    # Copying and comparison support.
     1.8 +
     1.9 +    def as_tuple(self):
    1.10 +        return self.level, self.args, self.qualifier, self.selecting
    1.11 +
    1.12 +    def copy(self):
    1.13 +        return self.__class__(*self.as_tuple())
    1.14 +
    1.15 +    def __cmp__(self, other):
    1.16 +        return cmp(self.as_tuple(), other and other.as_tuple())
    1.17 +
    1.18  class Pattern(Selector):
    1.19  
    1.20      "A selector of time periods according to a repeating pattern."
    1.21 @@ -1003,6 +1014,11 @@
    1.22          self.args["interval"] = interval
    1.23          self.update_step()
    1.24  
    1.25 +    # Copying and comparison support.
    1.26 +
    1.27 +    def as_tuple(self):
    1.28 +        return self.level, self.args, self.qualifier, self.selecting, self.first
    1.29 +
    1.30  class Enum(Selector):
    1.31  
    1.32      "A generic value selector."