Ejemplo n.º 1
0
 def parse_search_argument(self, filter_type, value):
     if filter_type in ('any', 'all'):
         try:
             return [self.subtype.from_argument(elem)
                     for elem in split_with_escape(value, '|', '\\')]
         except ValueError, e:
             self._illegal_argument(value, str(e))
Ejemplo n.º 2
0
 def parse_search_argument(self, filter_type, value):
     """Parse search argument of type filter_type"""
     if filter_type == 'in':
         try:
             return [self.from_argument(elem)
                     for elem in split_with_escape(value, '|', '\\')]
         except ValueError, e:
             self._illegal_argument(value, str(e))
Ejemplo n.º 3
0
 def test_split_unknown_esc(self):
     gen = split_with_escape(r'abc\a', '|')
     self.assertRaises(ValueError, list, gen)
Ejemplo n.º 4
0
 def test_split_no_last_esc(self):
     gen = split_with_escape('abc\\', '|')
     self.assertRaises(ValueError, list, gen)
Ejemplo n.º 5
0
 def test_split_esc_single_char(self):
     gen = split_with_escape('abc', '|', 'escape')
     self.assertRaises(ValueError, list, gen)
Ejemplo n.º 6
0
 def test_split_empty(self):
     result = list(split_with_escape(r'abc||def|', '|'))
     self.assertEquals(['abc', '', 'def', ''], result)
Ejemplo n.º 7
0
 def test_split_with_esc_esc(self):
     result = list(split_with_escape(r'abc|def\\|qwe', '|'))
     self.assertEquals(['abc', 'def\\', 'qwe'], result)
Ejemplo n.º 8
0
 def test_split_simple(self):
     result = list(split_with_escape('abc|def|qwe', '|'))
     self.assertEquals(['abc', 'def', 'qwe'], result)
Ejemplo n.º 9
0
 def test_split_single(self):
     result = list(split_with_escape('abc', '|'))
     self.assertEquals(['abc'], result)
Ejemplo n.º 10
0
 def test_split_no_last_esc(self):
     gen = split_with_escape("abc\\", "|")
     self.assertRaises(ValueError, list, gen)
Ejemplo n.º 11
0
 def test_split_unknown_esc(self):
     gen = split_with_escape(r"abc\a", "|")
     self.assertRaises(ValueError, list, gen)
Ejemplo n.º 12
0
 def test_split_esc_single_char(self):
     gen = split_with_escape("abc", "|", "escape")
     self.assertRaises(ValueError, list, gen)
Ejemplo n.º 13
0
 def test_split_empty(self):
     result = list(split_with_escape(r"abc||def|", "|"))
     self.assertEquals(["abc", "", "def", ""], result)
Ejemplo n.º 14
0
 def test_split_with_esc_esc(self):
     result = list(split_with_escape(r"abc|def\\|qwe", "|"))
     self.assertEquals(["abc", "def\\", "qwe"], result)
Ejemplo n.º 15
0
 def test_split_simple(self):
     result = list(split_with_escape("abc|def|qwe", "|"))
     self.assertEquals(["abc", "def", "qwe"], result)
Ejemplo n.º 16
0
 def test_split_single(self):
     result = list(split_with_escape("abc", "|"))
     self.assertEquals(["abc"], result)