Пример #1
0
    def path(self, id, type, params):
        path = []
        while True:
            doc = self._getResource(id, type)
            if doc is None:
                raise RestException('Invalid resource id.')
            name = self._getResourceName(type, doc)
            path.insert(0, name)

            if type in ('file', 'item', 'folder'):
                id, type = self._getResourceParent(type, doc)
            else:
                break

        path.insert(0, type)
        return '/' + path_util.join(path)
Пример #2
0
    def path(self, id, params):
        path = []
        type = params['type']
        while True:
            doc = self._getResource(id, type)
            if doc is None:
                raise RestException('Invalid resource id.')
            name = self._getResourceName(type, doc)
            path.insert(0, name)

            if type in ('file', 'item', 'folder'):
                id, type = self._getResourceParent(type, doc)
            else:
                break

        path.insert(0, type)
        return '/' + path_util.join(path)
Пример #3
0
 def testJoinTokens(self):
     for pth, tokens in paths:
         self.assertEqual(path.join(tokens), pth)
Пример #4
0
 def testJoinTokens(self):
     for pth, tokens in paths:
         self.assertEqual(path.join(tokens), pth)
Пример #5
0
def testSplitAndJoin(pth, tokens):
    assert path.split(pth) == tokens
    assert path.join(tokens) == pth