Пример #1
0
 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)
Пример #2
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/'))
Пример #3
0
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])
Пример #4
0
 def lenCommonPrefix(self):
     return CommonPrefix.lenCommonPrefix(self._fileNameS)
Пример #5
0
 def _printFileList(self, thePref, theL):
     l = CommonPrefix.lenCommonPrefix(theL)
     print(thePref, [f[l + 1:] for f in theL])
Пример #6
0
 def test_lenCommonPrefix_one(self):
     paths = ['path/to/file']
     result = CommonPrefix.lenCommonPrefix(paths)
     self.assertEqual(result, len('path/to/'))
Пример #7
0
 def test_lenCommonPrefix_empty(self):
     result = CommonPrefix.lenCommonPrefix([])
     self.assertEqual(result, 0)