예제 #1
0
    def _matches(self, sequence):
        if not hasmethod(sequence, '__len__') or not hasmethod(sequence, '__iter__'):
            return False
        
        if len(sequence) == 0:
			return False
        for item in sequence:
            if not self.matcher.matches(item):
                return False
        return True
예제 #2
0
 def _matches(self, dictionary):
     if hasmethod(dictionary, 'itervalues'):
         for value in dictionary.itervalues():
             if self.value_matcher.matches(value):
                 return True
     return False
예제 #3
0
 def _matches(self, dictionary):
     if hasmethod(dictionary, 'iterkeys'):
         for key in dictionary.iterkeys():
             if self.key_matcher.matches(key):
                 return True
     return False
 def _matches(self, item):
     if not hasmethod(item, '__len__'):
         return False
     return len(item) == 0
예제 #5
0
 def _matches(self, sequence):
     if hasmethod(sequence, '__iter__'):
         for item in sequence:
             if self.element_matcher.matches(item):
                 return True
     return False
예제 #6
0
 def _matches(self, item):
     if not hasmethod(item, '__len__'):
         return False
     return self.len_matcher.matches(len(item))
예제 #7
0
 def _matches(self, dictionary):
     if hasmethod(dictionary, 'iteritems'):
         for key, value in dictionary.iteritems():
             if self.key_matcher.matches(key) and self.value_matcher.matches(value):
                 return True
     return False
예제 #8
0
 def _matches(self, item):
     if not hasmethod(item, 'endswith'):
         return False
     return item.endswith(self.substring)
예제 #9
0
 def _matches(self, item):
     if not hasmethod(item, 'find'):
         return False
     return item.find(self.substring) >= 0