def test_lenCommonPrefix_many_nothing_in_common(self): paths = [ 'apath/to/file_a', 'bpath/to/another/file_a', 'cpath/to/yetanother/file_a', ] result = CommonPrefix.lenCommonPrefix(paths) self.assertEqual(result, 0)
def test_lenCommonPrefix_many(self): paths = [ 'path/to/file_a', 'path/to/another/file_a', 'path/to/yetanother/file_a', ] result = CommonPrefix.lenCommonPrefix(paths) self.assertEqual(result, len('path/to/'))
def _removeCommonPrefixFromResults(titlePathTupleS): l = CommonPrefix.lenCommonPrefix([r.ituPath for r in titlePathTupleS]) prefixOut = '' if l > 0: assert len(titlePathTupleS) > 0 # prefixOut = titlePathTupleS[0][1][:l] for tpt in titlePathTupleS: if tpt[1] is not None: prefixOut = tpt[1][:l] break return prefixOut, sorted( [PpProcessResult(t[l:], p, i) for t, p, i in titlePathTupleS])
def lenCommonPrefix(self): return CommonPrefix.lenCommonPrefix(self._fileNameS)
def _printFileList(self, thePref, theL): l = CommonPrefix.lenCommonPrefix(theL) print(thePref, [f[l + 1:] for f in theL])
def test_lenCommonPrefix_one(self): paths = ['path/to/file'] result = CommonPrefix.lenCommonPrefix(paths) self.assertEqual(result, len('path/to/'))
def test_lenCommonPrefix_empty(self): result = CommonPrefix.lenCommonPrefix([]) self.assertEqual(result, 0)