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