def match(self, path): """ Returns the first route matching path. Returns None if no matches were found. """ return self.get(parse_path(path), RouteList()).match(path)
def should_turn_paths_into_tuples(self): self.assertEqual(('home', 'index', 'weeble'), parse_path('/home/index/weeble')) self.assertEqual(('home', 'index', 'weeble'), parse_path('/home/index/weeble/')) self.assertEqual(('home', 'index', 'weeble'), parse_path('home/index/weeble')) self.assertEqual(('home', 'index', 'weeble'), parse_path('home/index/weeble/'))
def add(self, route): """ Adds route to the tree for each path in route.paths(). """ for path in route.paths(): self.setdefault(parse_path(path), RouteList()).add(route)