mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2026-01-01 09:20:49 +00:00
Basic talent scripts
This commit is contained in:
@@ -14,6 +14,7 @@ from .validations import *
|
|||||||
|
|
||||||
from ptulsconv.pdf.supervisor_1pg import output_report as output_supervisor_1pg
|
from ptulsconv.pdf.supervisor_1pg import output_report as output_supervisor_1pg
|
||||||
from ptulsconv.pdf.line_count import output_report as output_line_count
|
from ptulsconv.pdf.line_count import output_report as output_line_count
|
||||||
|
from ptulsconv.pdf.talent_sides import output_report as output_talent_sides
|
||||||
|
|
||||||
# field_map maps tags in the text export to fields in FMPXMLRESULT
|
# field_map maps tags in the text export to fields in FMPXMLRESULT
|
||||||
# - tuple field 0 is a list of tags, the first tag with contents will be used as source
|
# - tuple field 0 is a list of tags, the first tag with contents will be used as source
|
||||||
@@ -220,6 +221,7 @@ def convert(input_file, output_format='fmpxml', start=None, end=None, select_ree
|
|||||||
print("Sorry, the `full` output type is not yet supported.")
|
print("Sorry, the `full` output type is not yet supported.")
|
||||||
normalized_records = normalize_record_keys(parsed)
|
normalized_records = normalize_record_keys(parsed)
|
||||||
output_supervisor_1pg(normalized_records)
|
output_supervisor_1pg(normalized_records)
|
||||||
|
output_talent_sides(normalized_records)
|
||||||
output_line_count(normalized_records)
|
output_line_count(normalized_records)
|
||||||
elif output_format == 'fmpxml':
|
elif output_format == 'fmpxml':
|
||||||
if xsl is None:
|
if xsl is None:
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
from reportlab.pdfbase.pdfmetrics import (getAscent, getDescent)
|
from reportlab.pdfbase.pdfmetrics import (getAscent, getDescent)
|
||||||
|
|
||||||
|
|
||||||
|
def draw_title_block(canvas, rect, record):
|
||||||
|
(supervisor, client,), title = rect.divide_y([16., 16., ])
|
||||||
|
title.draw_text_cell(canvas, record['Title'], "Futura", 18, inset_y=2.)
|
||||||
|
client.draw_text_cell(canvas, record.get('Client', ''), "Futura", 11, inset_y=2.)
|
||||||
|
supervisor.draw_text_cell(canvas, record.get('Supervisor', ''), "Futura", 11, inset_y=2.)
|
||||||
|
|
||||||
|
|
||||||
class GRect:
|
class GRect:
|
||||||
def __init__(self, x, y, width, height, debug_name=None):
|
def __init__(self, x, y, width, height, debug_name=None):
|
||||||
self.x = x
|
self.x = x
|
||||||
@@ -52,7 +59,7 @@ class GRect:
|
|||||||
return (GRect(self.min_x, self.min_y, at, self.height),
|
return (GRect(self.min_x, self.min_y, at, self.height),
|
||||||
GRect(self.min_x + at, self.y, self.width - at, self.height))
|
GRect(self.min_x + at, self.y, self.width - at, self.height))
|
||||||
|
|
||||||
def split_y(self, at, direction='u') :
|
def split_y(self, at, direction='u'):
|
||||||
if at >= self.height:
|
if at >= self.height:
|
||||||
return None, self
|
return None, self
|
||||||
elif at <= 0:
|
elif at <= 0:
|
||||||
@@ -189,4 +196,3 @@ class GRect:
|
|||||||
y = y - leading
|
y = y - leading
|
||||||
|
|
||||||
canvas.restoreState()
|
canvas.restoreState()
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from reportlab.lib.pagesizes import letter
|
|||||||
from reportlab.lib.styles import getSampleStyleSheet
|
from reportlab.lib.styles import getSampleStyleSheet
|
||||||
from reportlab.platypus import Paragraph
|
from reportlab.platypus import Paragraph
|
||||||
|
|
||||||
from .common import GRect
|
from .common import GRect, draw_title_block
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
@@ -17,14 +17,6 @@ import datetime
|
|||||||
def draw_header_block(canvas, rect, record):
|
def draw_header_block(canvas, rect, record):
|
||||||
rect.draw_text_cell(canvas, record['Cue Number'], "Helvetica", 44, vertical_align='m')
|
rect.draw_text_cell(canvas, record['Cue Number'], "Helvetica", 44, vertical_align='m')
|
||||||
|
|
||||||
|
|
||||||
def draw_title_block(canvas, rect, record):
|
|
||||||
(supervisor, client,), title = rect.divide_y([16., 16., ])
|
|
||||||
title.draw_text_cell(canvas, record['Title'], "Futura", 18, inset_y=2.)
|
|
||||||
client.draw_text_cell(canvas, record.get('Client', ''), "Futura", 11, inset_y=2.)
|
|
||||||
supervisor.draw_text_cell(canvas, record.get('Supervisor', ''), "Futura", 11, inset_y=2.)
|
|
||||||
|
|
||||||
|
|
||||||
def draw_character_row(canvas, rect, record):
|
def draw_character_row(canvas, rect, record):
|
||||||
label_frame, value_frame = rect.split_x(1.25 * inch)
|
label_frame, value_frame = rect.split_x(1.25 * inch)
|
||||||
label_frame.draw_text_cell(canvas, "CHARACTER", "Futura", 10, force_baseline=9.)
|
label_frame.draw_text_cell(canvas, "CHARACTER", "Futura", 10, force_baseline=9.)
|
||||||
|
|||||||
68
ptulsconv/pdf/talent_sides.py
Normal file
68
ptulsconv/pdf/talent_sides.py
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
from .common import GRect, draw_title_block
|
||||||
|
from reportlab.lib.units import inch
|
||||||
|
from reportlab.lib.pagesizes import letter
|
||||||
|
|
||||||
|
from reportlab.platypus import BaseDocTemplate, Paragraph, Spacer, KeepTogether, Table, HRFlowable, \
|
||||||
|
SimpleDocTemplate, PageTemplate, Frame
|
||||||
|
from reportlab.lib.styles import getSampleStyleSheet
|
||||||
|
from reportlab.lib import colors
|
||||||
|
|
||||||
|
from reportlab.pdfbase import pdfmetrics
|
||||||
|
from reportlab.pdfbase.ttfonts import TTFont
|
||||||
|
|
||||||
|
page_box = GRect(inch * 0.5, inch * 0.5, letter[0] - inch, letter[1] - inch)
|
||||||
|
title_box, page_box = page_box.split_y(0.875 * inch, 'd')
|
||||||
|
header_block, title_block = title_box.split_x(inch * 4.)
|
||||||
|
|
||||||
|
|
||||||
|
def output_report(records):
|
||||||
|
character_numbers = set([n['Character Number'] for n in records['events']])
|
||||||
|
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
||||||
|
|
||||||
|
for n in character_numbers:
|
||||||
|
lines = [line for line in records['events']
|
||||||
|
if 'Omit' not in line.keys() and line['Character Number'] == n]
|
||||||
|
|
||||||
|
page_template = PageTemplate(id="Main",
|
||||||
|
frames=[Frame(page_box.min_x, page_box.min_y, page_box.width, page_box.height)],
|
||||||
|
onPage=lambda canv, _: draw_title_block(canv, title_block, lines[0]))
|
||||||
|
|
||||||
|
sorted(lines, key=lambda line: line['PT.Clip.Start_Seconds'])
|
||||||
|
|
||||||
|
doc = BaseDocTemplate("%s_%s_Script.pdf" % (n, lines[0]['Character Name']),
|
||||||
|
pagesize=letter, leftMargin=0.5 * inch,
|
||||||
|
rightMargin=0.5 * inch, topMargin=0.5 * inch, bottomMargin=0.5 * inch)
|
||||||
|
|
||||||
|
doc.addPageTemplates([page_template])
|
||||||
|
story = []
|
||||||
|
|
||||||
|
prompt_style = getSampleStyleSheet()['Normal']
|
||||||
|
prompt_style.fontName = 'Futura'
|
||||||
|
prompt_style.fontSize = 18
|
||||||
|
|
||||||
|
prompt_style.leading = 24
|
||||||
|
prompt_style.leftIndent = 1.5 * inch
|
||||||
|
prompt_style.rightIndent = 1.5 * inch
|
||||||
|
|
||||||
|
number_style = getSampleStyleSheet()['Normal']
|
||||||
|
number_style.fontName = 'Futura'
|
||||||
|
number_style.fontSize = 14
|
||||||
|
|
||||||
|
number_style.leading = 24
|
||||||
|
number_style.leftIndent = 0.
|
||||||
|
number_style.rightIndent = 0.
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
data_block = [[Paragraph(line['Cue Number'], number_style),
|
||||||
|
Paragraph(line['PT.Clip.Start'] + " - " + line['PT.Clip.Finish'], number_style)
|
||||||
|
]]
|
||||||
|
story.append(
|
||||||
|
KeepTogether(
|
||||||
|
[HRFlowable(width='100%', color=colors.black),
|
||||||
|
Table(data=data_block, colWidths=[1.5 * inch, 6. * inch]),
|
||||||
|
Paragraph(line['Line'], prompt_style),
|
||||||
|
Spacer(1., inch * 1.5)]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
doc.build(story)
|
||||||
Reference in New Issue
Block a user