Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mgaitan / waliki / 357

7 Aug 2017 - 8:18 coverage: 74.969% (-0.03%) from 75.0%
357

Pull #147

travis-ci

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
Consistent handling of executable paths for external tools.
Pull Request #147: Consistent handling of executable paths for external tools.

8 of 10 new or added lines in 4 files covered. (80.0%)

2 existing lines in 1 file now uncovered.

1216 of 1622 relevant lines covered (74.97%)

6.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0
/waliki/pdf/views.py
1
import tempfile
!
NEW
2
from sh import Command
!
3
from django.shortcuts import get_object_or_404
!
4
from waliki.models import Page
!
5
from waliki.utils import send_file
!
6
from waliki.settings import WALIKI_PDF_INCLUDE_TITLE
!
7
from waliki.settings import WALIKI_PDF_RST2PDF_BIN
!
8
from waliki.acl import permission_required
!
9

NEW
10
rst2pdf = Command(WALIKI_PDF_RST2PDF_BIN).bake(_tty_out=False)
!
11

12

13
@permission_required('view_page')
!
14
def pdf(request, slug):
15
    page = get_object_or_404(Page, slug=slug)
!
16

17
    with tempfile.NamedTemporaryFile(suffix='.pdf') as output:
!
18
        outfile = output.name
!
19
    if WALIKI_PDF_INCLUDE_TITLE:
!
20
        line = "/" * len(page.title)
!
21
        title = "%s\n%s\n%s\n\n" % (line, page.title, line)
!
22
        with tempfile.NamedTemporaryFile(suffix='.rst', mode="w", delete=False) as infile:
!
23
            infile.file.write(title + page.raw)
!
24
            infile = infile.name
!
25
    else:
26
        infile = page.abspath
!
27
    rst2pdf(infile, o=outfile)
!
28
    filename = page.title.replace('/', '-').replace('..', '-')
!
29
    return send_file(outfile, filename="%s.pdf" % filename)
!
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2023 Coveralls, Inc