Browse Source

linted

master
Holger Frey 6 years ago
parent
commit
1fbe133e7f
  1. 6
      pdftools/cli.py
  2. 4
      pdftools/formfill.py
  3. 1
      pdftools/nameplate.py
  4. 9
      pdftools/ruler.py

6
pdftools/cli.py

@ -66,13 +66,13 @@ def nameplates(attendees, logo, size, adjust_x, adjust_y):
size and adjustment options. size and adjustment options.
""" """
if logo is not None: if logo is not None:
logo = nameplate.Logo(logo, size * mm, adjust_x=adjust_x, adjust_y=adjust_y) logo = nameplate.Logo(
logo, size * mm, adjust_x=adjust_x, adjust_y=adjust_y
)
npc = nameplate.NamePlateCards(logo) npc = nameplate.NamePlateCards(logo)
npc.generate(attendees, show=True) npc.generate(attendees, show=True)
@click.command() @click.command()
@click.argument( @click.argument(
"pdf", "pdf",

4
pdftools/formfill.py

@ -1,11 +1,9 @@
import pdfrw import pdfrw
import subprocess import subprocess
import itertools
import tempfile import tempfile
from pathlib import Path from pathlib import Path
from reportlab.pdfgen import canvas from reportlab.pdfgen import canvas
from reportlab.lib.units import mm
from reportlab.lib.pagesizes import A4 from reportlab.lib.pagesizes import A4
@ -48,5 +46,3 @@ def fill(original_form, values, draw_function, output_file="filled.pdf"):
# write the combined file to the output # write the combined file to the output
pdfrw.PdfWriter().write(output_file, form) pdfrw.PdfWriter().write(output_file, form)
subprocess.run(["open", output_file]) subprocess.run(["open", output_file])

1
pdftools/nameplate.py

@ -41,6 +41,7 @@ false_and_true = itertools.cycle([False, True])
imtek_logo_path = Path(__file__).parent / "logo_imtek.png" imtek_logo_path = Path(__file__).parent / "logo_imtek.png"
class NamePlateCards: class NamePlateCards:
def __init__( def __init__(
self, self,

9
pdftools/ruler.py

@ -5,20 +5,19 @@ from . import formfill
def ruler_overlay(original_form): def ruler_overlay(original_form):
def ruler(c, item): def ruler(c, item):
c.setStrokeColorRGB(0, 0, 1) c.setStrokeColorRGB(0, 0, 1)
c.setFillColorRGB(0, 0, 1) c.setFillColorRGB(0, 0, 1)
c.setLineWidth(0.5) c.setLineWidth(0.5)
c.setFont("Helvetica", 8) c.setFont("Helvetica", 8)
x_grid = [x*mm for x in range(10, 210, 10)] x_grid = [x * mm for x in range(10, 210, 10)]
y_grid = [y*mm for y in range(10, 297, 10)] y_grid = [y * mm for y in range(10, 297, 10)]
c.grid(x_grid, y_grid) c.grid(x_grid, y_grid)
for x in range(10, 210, 10): for x in range(10, 210, 10):
c.drawString((x-2)*mm, 5*mm, str(x)) c.drawString((x - 2) * mm, 5 * mm, str(x))
for y in range(10, 297, 10): for y in range(10, 297, 10):
c.drawString(4*mm, (y-0.5)*mm, str(y)) c.drawString(4 * mm, (y - 0.5) * mm, str(y))
ofp = Path(original_form) ofp = Path(original_form)
out_path = ofp.parent / f"{ofp.stem}_ruler.pdf" out_path = ofp.parent / f"{ofp.stem}_ruler.pdf"

Loading…
Cancel
Save