Ejemplo n.º 1
0
    def reportForFile(self, filePath: FilePath, sandboxedPath: SandboxedPath,
                      request: TwistedRequest) -> IResource:

        if filePath.splitext()[1] == '.gz':
            # Try to use fancy formatting.
            fileName = sandboxedPath.path[-1]
            presenter = createPresenter(partial(openGzip, filePath.path),
                                        fileName)
            if presenter is not None:
                # pylint: disable=too-many-function-args
                # https://github.com/PyCQA/pylint/issues/3492
                return ReportResource(presenter, fileName)

        # Redirect to sandbox to serve the report as-is.
        urlPath = [b'..'
                   ] * (len(request.postpath) - 1 + len(sandboxedPath.path))
        urlPath.append(sandboxedPath.createURL().encode())
        urlPath += request.postpath
        return Redirect(b'/'.join(urlPath))