mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Refactored report template
This commit is contained in:
@@ -57,7 +57,12 @@ class ADRDocTemplate(BaseDocTemplate):
|
||||
BaseDocTemplate.build(self, flowables, filename, canvasmaker)
|
||||
|
||||
|
||||
def make_doc_template(page_size, filename, document_title, record: ADRLine, document_header="",
|
||||
def make_doc_template(page_size, filename, document_title,
|
||||
title: str,
|
||||
supervisor: str,
|
||||
document_header: str,
|
||||
client: str,
|
||||
document_date: str,
|
||||
left_margin=0.5 * inch) -> ADRDocTemplate:
|
||||
right_margin = top_margin = bottom_margin = 0.5 * inch
|
||||
page_box = GRect(0., 0., page_size[0], page_size[1])
|
||||
@@ -72,13 +77,19 @@ def make_doc_template(page_size, filename, document_title, record: ADRLine, docu
|
||||
|
||||
page_template = PageTemplate(id="Main",
|
||||
frames=[Frame(page_box.min_x, page_box.min_y, page_box.width, page_box.height)],
|
||||
onPage=lambda c, _: draw_header_footer(c, title_box, report_box, footer_box, record,
|
||||
onPage=lambda c, _: draw_header_footer(c, title_box,
|
||||
report_box,
|
||||
footer_box,
|
||||
title=title,
|
||||
supervisor=supervisor,
|
||||
client=client,
|
||||
document_date=document_date,
|
||||
doc_title=document_header))
|
||||
|
||||
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
||||
doc = ADRDocTemplate(filename,
|
||||
title=document_title,
|
||||
author=record.supervisor,
|
||||
author=supervisor,
|
||||
pagesize=page_size,
|
||||
leftMargin=left_margin, rightMargin=right_margin,
|
||||
topMargin=top_margin, bottomMargin=bottom_margin)
|
||||
@@ -99,34 +110,36 @@ def time_format(mins, zero_str=""):
|
||||
return "%i:%02i" % (hh, mm)
|
||||
|
||||
|
||||
def draw_header_footer(a_canvas: ReportCanvas, title_box, doc_title_box, footer_box, record: ADRLine, doc_title=""):
|
||||
(supervisor, client,), title = title_box.divide_y([16., 16., ])
|
||||
title.draw_text_cell(a_canvas, record.title, "Futura", 18, inset_y=2., inset_x=5.)
|
||||
client.draw_text_cell(a_canvas, record.client, "Futura", 11, inset_y=2., inset_x=5.)
|
||||
def draw_header_footer(a_canvas: ReportCanvas, right_box, left_box, footer_box,
|
||||
title: str, supervisor: str, document_date: str, client: str, doc_title=""):
|
||||
|
||||
(_supervisor_box, client_box,), title_box = right_box.divide_y([16., 16., ])
|
||||
title_box.draw_text_cell(a_canvas, title, "Futura", 18, inset_y=2., inset_x=5.)
|
||||
client_box.draw_text_cell(a_canvas, client, "Futura", 11, inset_y=2., inset_x=5.)
|
||||
|
||||
a_canvas.saveState()
|
||||
a_canvas.setLineWidth(0.5)
|
||||
tline = a_canvas.beginPath()
|
||||
tline.moveTo(doc_title_box.min_x, title_box.min_y)
|
||||
tline.lineTo(title_box.max_x, title_box.min_y)
|
||||
tline.moveTo(left_box.min_x, right_box.min_y)
|
||||
tline.lineTo(right_box.max_x, right_box.min_y)
|
||||
a_canvas.drawPath(tline)
|
||||
|
||||
tline2 = a_canvas.beginPath()
|
||||
tline2.moveTo(title_box.min_x, title_box.min_y)
|
||||
tline2.lineTo(title_box.min_x, title_box.max_y)
|
||||
tline2.moveTo(right_box.min_x, left_box.min_y)
|
||||
tline2.lineTo(right_box.min_x, left_box.max_y)
|
||||
a_canvas.drawPath(tline2)
|
||||
a_canvas.restoreState()
|
||||
|
||||
(doc_title_cell, spotting_version_cell,), _ = doc_title_box.divide_y([18., 14], direction='d')
|
||||
(doc_title_cell, spotting_version_cell,), _ = left_box.divide_y([18., 14], direction='d')
|
||||
|
||||
doc_title_cell.draw_text_cell(a_canvas, doc_title, 'Futura', 14., inset_y=2.)
|
||||
|
||||
if record.spot is not None:
|
||||
spotting_version_cell.draw_text_cell(a_canvas, record.spot, 'Futura', 12., inset_y=2.)
|
||||
if document_date is not None:
|
||||
spotting_version_cell.draw_text_cell(a_canvas, document_date, 'Futura', 12., inset_y=2.)
|
||||
|
||||
a_canvas.setFont('Futura', 11.)
|
||||
a_canvas.drawCentredString(footer_box.min_x + footer_box.width / 2., footer_box.min_y,
|
||||
record.supervisor or "")
|
||||
if supervisor is not None:
|
||||
a_canvas.setFont('Futura', 11.)
|
||||
a_canvas.drawCentredString(footer_box.min_x + footer_box.width / 2., footer_box.min_y, supervisor)
|
||||
|
||||
|
||||
class GRect:
|
||||
|
||||
25
ptulsconv/pdf/continuity.py
Normal file
25
ptulsconv/pdf/continuity.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from fractions import Fraction
|
||||
from typing import Tuple, List
|
||||
|
||||
from reportlab.lib.pagesizes import portrait, letter
|
||||
from reportlab.lib.units import inch
|
||||
|
||||
from ptulsconv.broadcast_timecode import TimecodeFormat
|
||||
from ptulsconv.pdf import make_doc_template
|
||||
|
||||
|
||||
def output_report(scenes: List[Tuple[str, Fraction, Fraction]],
|
||||
tc_display_format: TimecodeFormat, title: str,
|
||||
page_size=portrait(letter)):
|
||||
|
||||
filename = "%s Continuity" % title
|
||||
document_header = "Continuity"
|
||||
|
||||
doc = make_doc_template(page_size=page_size,
|
||||
filename=filename, document_title=title,
|
||||
title="",
|
||||
client="",
|
||||
document_date="",
|
||||
supervisor="",
|
||||
document_header=document_header,
|
||||
left_margin=0.75 * inch)
|
||||
@@ -206,8 +206,10 @@ def output_report(lines: List[ADRLine], reel_list: List[str], include_omitted=Fa
|
||||
title = "%s Line Count" % lines[0].title
|
||||
filename = title + '.pdf'
|
||||
doc = make_doc_template(page_size=page_size, filename=filename,
|
||||
document_title=title,
|
||||
record=lines[0],
|
||||
document_title=title, title=lines[0].title,
|
||||
document_date=lines[0].spot,
|
||||
client=lines[0].client,
|
||||
supervisor=lines[0].supervisor,
|
||||
document_header='Line Count')
|
||||
|
||||
# header_data, header_style, header_widths = build_header(columns_widths)
|
||||
|
||||
@@ -126,7 +126,11 @@ def generate_report(page_size, lines: List[ADRLine], tc_rate: TimecodeFormat, ch
|
||||
filename = title + ".pdf"
|
||||
doc = make_doc_template(page_size=page_size,
|
||||
filename=filename, document_title=title,
|
||||
record=lines[0], document_header=document_header,
|
||||
document_header=document_header,
|
||||
title=lines[0].title,
|
||||
supervisor=lines[0].supervisor,
|
||||
client=lines[0].client,
|
||||
document_date=lines[0].spot,
|
||||
left_margin=0.75 * inch)
|
||||
story = build_story(lines, tc_rate)
|
||||
doc.build(story)
|
||||
|
||||
@@ -30,7 +30,11 @@ def output_report(lines: List[ADRLine], tc_display_format: TimecodeFormat):
|
||||
filename = "%s_%s_%s_ADR Script.pdf" % (char_lines[0].title, n, character_name)
|
||||
|
||||
doc = make_doc_template(page_size=letter, filename=filename, document_title=title,
|
||||
record=char_lines[0], document_header=character_name)
|
||||
title=char_lines[0].title,
|
||||
document_date=char_lines[0].spot,
|
||||
supervisor=char_lines[0].supervisor,
|
||||
client=char_lines[0].client,
|
||||
document_header=character_name)
|
||||
|
||||
story = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user