예제 #1
0
 def __init__(self, cmd="", inputs=None, outputs=None, desc="", **kwds):
     self._inputs = as_tuple(inputs)
     self._outputs = as_tuple(outputs)
     desc_kw = dict(i=self._inputs, o=self._outputs)
     desc_kw.update(kwds)
     desc = desc.format(**desc_kw)
     cmd_kw = dict(i=shquote(self._inputs), o=shquote(self._outputs))
     cmd_kw.update(kwds)
     cmd = vformat_list(string.Formatter(), cmd, [], cmd_kw)
     if not desc:
         desc = cmd
     super().__init__(cmd=cmd, desc=desc)
예제 #2
0
def _format_filelist_shargs(filelist):
    return " ".join(shquote(i) for i in sorted(filelist))
예제 #3
0
 def test_stringify_list(self):
     self.assertEqual(shquote([PathLib("1 0"), PathLib("2 0")]),
                      ["'1 0'", "'2 0'"])
예제 #4
0
 def test_stringify_singleton(self):
     self.assertEqual(shquote(PathLib("1 0")), "'1 0'")
예제 #5
0
 def test_set_of_strings(self):
     r = shquote(frozenset(("a b", "c d")))
     self.assertCountEqual(r, ("'a b'", "'c d'"))
     self.assertIs(type(r), frozenset)
예제 #6
0
 def test_tuple_of_strings(self):
     r = shquote(("a b", "c d"))
     self.assertCountEqual(r, ("'a b'", "'c d'"))
     self.assertIs(type(r), tuple)
예제 #7
0
 def test_list_of_strings(self):
     r = shquote(["a b", "c d"])
     self.assertCountEqual(r, ("'a b'", "'c d'"))
     self.assertIs(type(r), list)
예제 #8
0
 def test_single_string(self):
     self.assertEqual(shquote("a b"), "'a b'")
예제 #9
0
 def convert_field(self, value, conversion):
     if conversion == "q":
         return shquote(value)
     return super().convert_field(value, conversion)
예제 #10
0
 def formatter(self):
     return " ".join(shquote(as_flat_list(getattr(self, name))))