Exemplo n.º 1
0
    def structure(self, request, datefmt='isodate'):
        """\
        This method is implemented as a wrapper around webcommands.file
        and returns a structure.
        """

        # XXX deprecate this method?

        try:
            it = webcommands.file(self, request, _t)
            return utils.add_aentries(it, datefmt)
        except LookupError:
            if self.path:
                result = utils.match_subrepo(self.ctx.substate, self.path)
                if result:
                    return result
                raise PathNotFoundError("path '%s' not found" % self.path)
            else:
                raise RepoEmptyError('repository is empty')
Exemplo n.º 2
0
    def pathinfo(self, path):

        if path in self.files():
            return self.fileinfo(path)

        try:
            listing = self.listdir(path)
            # consider using an iterator?
            contents = lambda: listing
            data = self.format(**{
                'permissions': 'drwxr-xr-x',
                'node': self.rev,
                'date': '',
                'size': '',
                'path': path,
                'contents': contents,
            })
        except PathNotFoundError:
            # attempt to look for subrepo
            ctx = self.storage._ctx
            substate = ctx.substate
            gen = match_subrepo(substate, path)
            if not gen:
                raise  # re-raise the PathNotFound
            keys = gen.next()
            # General syntax.
            data = self.format(**{
                'permissions': 'lrwxrwxrwx',
                'contenttype': None,  # XXX unnecessary for now
                'node': self.rev,
                'date': '',
                'size': '',
                'path': path,
                'desc': '',
                'contents': '',
                'external': keys,
            })
        return data