예제 #1
0
 def test_match_order(self):
     hay = [6, 5, 4, 3, 2, 1]
     priors = []
     for i in range(0, 6):
         priors.append(i + 1)
         matches = misc.look_for(hay, priors)
         self.assertGreater(0, len(matches))
         self.assertIsSuperAndSubsequence(hay, matches)
     hay = [10, 1, 15, 3, 5, 8, 44]
     self.assertEqual([1, 15], misc.look_for(hay, [15, 1]))
     self.assertEqual([10, 44], misc.look_for(hay, [44, 10]))
예제 #2
0
 def test_match_order(self):
     hay = [6, 5, 4, 3, 2, 1]
     priors = []
     for i in range(0, 6):
         priors.append(i + 1)
         matches = misc.look_for(hay, priors)
         self.assertGreater(0, len(matches))
         self.assertIsSuperAndSubsequence(hay, matches)
     hay = [10, 1, 15, 3, 5, 8, 44]
     self.assertEqual([1, 15], misc.look_for(hay, [15, 1]))
     self.assertEqual([10, 44], misc.look_for(hay, [44, 10]))
예제 #3
0
파일: storage.py 프로젝트: mhorban/taskflow
 def _locate_providers(looking_for, possible_providers,
                       scope_walker=None):
     """Finds the accessible providers."""
     default_providers = []
     for p in possible_providers:
         if p.name is _TRANSIENT_PROVIDER:
             default_providers.append((p, self._transients))
         if p.name == self.injector_name:
             default_providers.append((p, _get_results(looking_for, p)))
     if default_providers:
         return default_providers
     if scope_walker is not None:
         scope_iter = iter(scope_walker)
     else:
         scope_iter = iter([])
     extractor = lambda p: p.name
     for names in scope_iter:
         # *Always* retain the scope ordering (if any matches
         # happen); instead of retaining the possible provider match
         # order (which isn't that important and may be different from
         # the scope requested ordering).
         providers = misc.look_for(names, possible_providers,
                                   extractor=extractor)
         if providers:
             return [(p, _get_results(looking_for, p))
                     for p in providers]
     return []
예제 #4
0
파일: storage.py 프로젝트: suneelb/taskflow
 def _locate_providers(looking_for,
                       possible_providers,
                       scope_walker=None):
     """Finds the accessible providers."""
     default_providers = []
     for p in possible_providers:
         if p.name is _TRANSIENT_PROVIDER:
             default_providers.append((p, self._transients))
         if p.name == self.injector_name:
             default_providers.append((p, _get_results(looking_for, p)))
     if default_providers:
         return default_providers
     if scope_walker is not None:
         scope_iter = iter(scope_walker)
     else:
         scope_iter = iter([])
     extractor = lambda p: p.name
     for names in scope_iter:
         # *Always* retain the scope ordering (if any matches
         # happen); instead of retaining the possible provider match
         # order (which isn't that important and may be different from
         # the scope requested ordering).
         providers = misc.look_for(names,
                                   possible_providers,
                                   extractor=extractor)
         if providers:
             return [(p, _get_results(looking_for, p))
                     for p in providers]
     return []
예제 #5
0
 def test_no_matches(self):
     hay = [9, 10, 11]
     self.assertEqual([], misc.look_for(hay, [1, 2, 3]))
예제 #6
0
 def test_no_matches(self):
     hay = [9, 10, 11]
     self.assertEqual([], misc.look_for(hay, [1, 2, 3]))