예제 #1
0
파일: types.py 프로젝트: altai/altai-api
 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))
예제 #2
0
파일: types.py 프로젝트: altai/altai-api
 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))
예제 #3
0
 def test_split_unknown_esc(self):
     gen = split_with_escape(r'abc\a', '|')
     self.assertRaises(ValueError, list, gen)
예제 #4
0
 def test_split_no_last_esc(self):
     gen = split_with_escape('abc\\', '|')
     self.assertRaises(ValueError, list, gen)
예제 #5
0
 def test_split_esc_single_char(self):
     gen = split_with_escape('abc', '|', 'escape')
     self.assertRaises(ValueError, list, gen)
예제 #6
0
 def test_split_empty(self):
     result = list(split_with_escape(r'abc||def|', '|'))
     self.assertEquals(['abc', '', 'def', ''], result)
예제 #7
0
 def test_split_with_esc_esc(self):
     result = list(split_with_escape(r'abc|def\\|qwe', '|'))
     self.assertEquals(['abc', 'def\\', 'qwe'], result)
예제 #8
0
 def test_split_simple(self):
     result = list(split_with_escape('abc|def|qwe', '|'))
     self.assertEquals(['abc', 'def', 'qwe'], result)
예제 #9
0
 def test_split_single(self):
     result = list(split_with_escape('abc', '|'))
     self.assertEquals(['abc'], result)
예제 #10
0
 def test_split_no_last_esc(self):
     gen = split_with_escape("abc\\", "|")
     self.assertRaises(ValueError, list, gen)
예제 #11
0
 def test_split_unknown_esc(self):
     gen = split_with_escape(r"abc\a", "|")
     self.assertRaises(ValueError, list, gen)
예제 #12
0
 def test_split_esc_single_char(self):
     gen = split_with_escape("abc", "|", "escape")
     self.assertRaises(ValueError, list, gen)
예제 #13
0
 def test_split_empty(self):
     result = list(split_with_escape(r"abc||def|", "|"))
     self.assertEquals(["abc", "", "def", ""], result)
예제 #14
0
 def test_split_with_esc_esc(self):
     result = list(split_with_escape(r"abc|def\\|qwe", "|"))
     self.assertEquals(["abc", "def\\", "qwe"], result)
예제 #15
0
 def test_split_simple(self):
     result = list(split_with_escape("abc|def|qwe", "|"))
     self.assertEquals(["abc", "def", "qwe"], result)
예제 #16
0
 def test_split_single(self):
     result = list(split_with_escape("abc", "|"))
     self.assertEquals(["abc"], result)