コード例 #1
0
ファイル: completer.py プロジェクト: dextero/powercmd
 def _complete_generic_list(self,
                            inner_type: type,
                            incomplete_value: str):
     """
     Returns completions for a list of values of INNER_TYPE.
     """
     args = list(split_list(incomplete_value, allow_unmatched=True))
     return self._complete_value(inner_type, args[-1])
コード例 #2
0
ファイル: completer.py プロジェクト: dextero/powercmd
 def _complete_generic_tuple(self,
                             inner_types: Sequence[type],
                             incomplete_value: str):
     """
     Returns completions for one of tuple values matching one of INNER_TYPES.
     """
     args = list(split_list(incomplete_value, allow_unmatched=True))
     if len(args) > len(inner_types):
         return []
     return self._complete_value(inner_types[len(args) - 1], args[-1])
コード例 #3
0
ファイル: cmd.py プロジェクト: krwc/powercmd
        def construct_tuple(text):
            if text[0] == '(' and text[-1] == ')':
                text = text[1:-1]

            sub_txts = list(split_list(text))
            if len(sub_txts) != len(internal_types):
                raise TypeError('mismatched lengths: %d strings, %d tuple types' % (len(sub_txts), len(internal_types)))

            tuple_list = []
            for cls, txt in zip(internal_types, sub_txts):
                tuple_list.append(self.get_constructor(cls)(txt))

            return tuple(tuple_list)
コード例 #4
0
ファイル: command_invoker.py プロジェクト: dextero/powercmd
        def construct_tuple(text):
            if text[0] == '(' and text[-1] == ')':
                text = text[1:-1]

            sub_txts = list(split_list(text))
            if len(sub_txts) != len(internal_types):
                raise TypeError('mismatched lengths: %d strings, %d tuple types' % (len(sub_txts), len(internal_types)))

            tuple_list = []
            for cls, txt in zip(internal_types, sub_txts):
                tuple_list.append(self.get_constructor(cls)(txt))

            return tuple(tuple_list)
コード例 #5
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_custom_separator(self):
     self.assertEqual(['foo', 'bar'],
                      list(split_list('foo|bar', separator='|')))
コード例 #6
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_mixed_delimiters(self):
     self.assertEqual(['(foo,"bar[baz]",{\'qux\'})', 'ggg'],
                      list(split_list('(foo,"bar[baz]",{\'qux\'}),ggg')))
コード例 #7
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_nested_parens(self):
     self.assertEqual(['(foo,(bar,baz))', '(qux)'],
                      list(split_list('(foo,(bar,baz)),(qux)')))
コード例 #8
0
 def test_mixed_delimiters(self):
     self.assertEqual(['(foo,"bar[baz]",{\'qux\'})', 'ggg'],
                      list(split_list('(foo,"bar[baz]",{\'qux\'}),ggg')))
コード例 #9
0
 def test_parens(self):
     self.assertEqual(['(foo,bar)', '(baz,qux)'],
                      list(split_list('(foo,bar),(baz,qux)')))
コード例 #10
0
ファイル: command_invoker.py プロジェクト: dextero/powercmd
 def construct_list(text):
     if text[0] == '[' and text[-1] == ']':
         text = text[1:-1]
     return [internal_ctor(txt) for txt in split_list(text)]
コード例 #11
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_empty(self):
     self.assertEqual([''], list(split_list('')))
コード例 #12
0
ファイル: cmd.py プロジェクト: dextero/nsh
 def complete_list(text):
     args = list(split_list(text, allow_unmatched=True))
     return completer(args[-1])
コード例 #13
0
 def test_single(self):
     self.assertEqual(['foo'], list(split_list('foo')))
コード例 #14
0
 def test_empty(self):
     self.assertEqual([''], list(split_list('')))
コード例 #15
0
 def test_unmatched_paren_allowed(self):
     self.assertEqual(['(foo,bar'],
                      list(split_list('(foo,bar', allow_unmatched=True)))
コード例 #16
0
 def test_unmatched_paren(self):
     with self.assertRaises(ValueError):
         list(split_list('(foo,bar'))
コード例 #17
0
 def test_custom_separator(self):
     self.assertEqual(['foo', 'bar'],
                      list(split_list('foo|bar', separator='|')))
コード例 #18
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_unmatched_paren(self):
     with self.assertRaises(ValueError):
         list(split_list('(foo,bar'))
コード例 #19
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_unmatched_paren_allowed(self):
     self.assertEqual(['(foo,bar'],
                      list(split_list('(foo,bar', allow_unmatched=True)))
コード例 #20
0
 def complete_list(text):
     args = list(split_list(text, allow_unmatched=True))
     return completer(args[-1])
コード例 #21
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_single(self):
     self.assertEqual(['foo'], list(split_list('foo')))
コード例 #22
0
 def construct_list(text):
     if text[0] == '[' and text[-1] == ']':
         text = text[1:-1]
     return [internal_ctor(txt) for txt in split_list(text)]
コード例 #23
0
 def test_multiple(self):
     self.assertEqual(['foo', 'bar'], list(split_list('foo,bar')))
コード例 #24
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_parens(self):
     self.assertEqual(['(foo,bar)', '(baz,qux)'],
                      list(split_list('(foo,bar),(baz,qux)')))
コード例 #25
0
ファイル: test_split_list.py プロジェクト: dextero/nsh
 def test_multiple(self):
     self.assertEqual(['foo','bar'], list(split_list('foo,bar')))
コード例 #26
0
 def test_nested_parens(self):
     self.assertEqual(['(foo,(bar,baz))', '(qux)'],
                      list(split_list('(foo,(bar,baz)),(qux)')))