Style fixes

This commit is contained in:
Jamie Hardt
2021-06-06 20:22:51 -07:00
parent 5559e1b057
commit e0b2d00332
7 changed files with 70 additions and 53 deletions

View File

@@ -6,9 +6,12 @@
<w>fmpxml</w>
<w>futura</w>
<w>leftpadding</w>
<w>lineafter</w>
<w>linebefore</w>
<w>ptulsconv</w>
<w>retval</w>
<w>smpte</w>
<w>subheader</w>
<w>timecode</w>
<w>timespan</w>
</words>

View File

@@ -160,8 +160,9 @@ def convert(input_file, major_mode='fmpxml', output=sys.stdout, warnings=True):
os.makedirs(reports_dir, exist_ok=False)
os.chdir(reports_dir)
reels = sorted([r for r in compiler.compile_all_time_spans() if r[0] == 'Reel'],
key=lambda x: x[2])
# reels = sorted([r for r in compiler.compile_all_time_spans() if r[0] == 'Reel'],
# key=lambda x: x[2])
reels = ['R1', 'R2', 'R3', 'R4', 'R5', 'R6']
create_adr_reports(adr_lines,
tc_display_format=session_tc_format,

View File

@@ -14,7 +14,6 @@ from ptulsconv.docparser.adr_entity import ADRLine
# TODO: A Generic report useful for spotting
# TODO: A report useful for M&E mixer's notes
# TODO: Address all style notes this file
# This is from https://code.activestate.com/recipes/576832/ for
# generating page count messages
@@ -62,7 +61,7 @@ def make_doc_template(page_size, filename, document_title,
supervisor: str,
document_header: str,
client: str,
document_date: str,
document_subheader: 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])
@@ -79,7 +78,8 @@ def make_doc_template(page_size, filename, document_title,
frames=[Frame(page_box.min_x, page_box.min_y, page_box.width, page_box.height)],
onPage=lambda c, _: draw_header_footer(c, report_box, title_box, footer_box,
title=title, supervisor=supervisor,
document_date=document_date, client=client,
document_subheader=document_subheader,
client=client,
doc_title=document_header))
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
@@ -95,7 +95,7 @@ def make_doc_template(page_size, filename, document_title,
return doc
def time_format(mins, zero_str=""):
def time_format(mins, zero_str="-"):
if mins == 0. and zero_str is not None:
return zero_str
elif mins < 60.:
@@ -107,7 +107,7 @@ def time_format(mins, zero_str=""):
def draw_header_footer(a_canvas: ReportCanvas, left_box, right_box, footer_box, title: str, supervisor: str,
document_date: str, client: str, doc_title=""):
document_subheader: 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.)
@@ -130,8 +130,8 @@ def draw_header_footer(a_canvas: ReportCanvas, left_box, right_box, footer_box,
doc_title_cell.draw_text_cell(a_canvas, doc_title, 'Futura', 14., inset_y=2.)
if document_date is not None:
spotting_version_cell.draw_text_cell(a_canvas, document_date, 'Futura', 12., inset_y=2.)
if document_subheader is not None:
spotting_version_cell.draw_text_cell(a_canvas, document_subheader, 'Futura', 12., inset_y=2.)
if supervisor is not None:
a_canvas.setFont('Futura', 11.)

View File

@@ -10,7 +10,8 @@ from ptulsconv.pdf import make_doc_template
# TODO: A Continuity
def output_report(scenes: List[Tuple[str, Fraction, Fraction]],
tc_display_format: TimecodeFormat, title: str,
tc_display_format: TimecodeFormat,
title: str, client: str, supervisor,
page_size=portrait(letter)):
filename = "%s Continuity" % title
@@ -18,9 +19,9 @@ def output_report(scenes: List[Tuple[str, Fraction, Fraction]],
doc = make_doc_template(page_size=page_size,
filename=filename, document_title=title,
title="",
client="",
document_date="",
supervisor="",
title=title,
client=client,
document_subheader="",
supervisor=supervisor,
document_header=document_header,
left_margin=0.75 * inch)

View File

@@ -7,7 +7,7 @@ from reportlab.lib.units import inch
from reportlab.lib.pagesizes import letter, portrait
from reportlab.lib import colors
from reportlab.platypus import Table, Paragraph
from reportlab.platypus import Table, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from .__init__ import time_format, make_doc_template
@@ -38,6 +38,47 @@ def build_columns(lines: List[ADRLine], reel_list: Optional[List[str]], show_pri
'summarize': False
})
columns.append({
'heading': 'TV',
'value_getter': lambda recs: len([r for r in recs if r.tv]),
'value_getter2': lambda recs: time_format(sum([r.time_budget_mins or 0.
for r in recs if r.tv])),
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER'),
('LINEBEFORE', (col_index, 0), (col_index, -1), 1., colors.black),
('LINEAFTER', (col_index, 0), (col_index, -1), .5, colors.gray)],
'width': num_column_width
})
columns.append({
'heading': 'Opt',
'value_getter': lambda recs: len([r for r in recs if r.optional]),
'value_getter2': lambda recs: time_format(sum([r.time_budget_mins or 0.
for r in recs if r.optional])),
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER'),
('LINEAFTER', (col_index, 0), (col_index, -1), .5, colors.gray)],
'width': num_column_width
})
columns.append({
'heading': 'Eff',
'value_getter': lambda recs: len([r for r in recs if r.effort]),
'value_getter2': lambda recs: time_format(sum([r.time_budget_mins or 0.
for r in recs if r.effort])),
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER')],
'width': num_column_width
})
columns.append({
'heading': '',
'value_getter': lambda _: '',
'value_getter2': lambda _: '',
'style_getter': lambda col_index: [
('LINEBEFORE', (col_index, 0), (col_index, -1), 1., colors.black),
('LINEAFTER', (col_index, 0), (col_index, -1), 1., colors.black),
],
'width': 2.
})
if len(reel_numbers) > 0:
# columns.append({
# 'heading': 'RX',
@@ -79,36 +120,6 @@ def build_columns(lines: List[ADRLine], reel_list: Optional[List[str]], show_pri
'width': num_column_width
})
columns.append({
'heading': 'TV',
'value_getter': lambda recs: len([r for r in recs if r.tv]),
'value_getter2': lambda recs: time_format(sum([r.time_budget_mins or 0.
for r in recs if r.tv])),
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER'),
('LINEBEFORE', (col_index, 0), (col_index, -1), 1., colors.black),
('LINEAFTER', (col_index, 0), (col_index, -1), .5, colors.gray)],
'width': num_column_width
})
columns.append({
'heading': 'Opt',
'value_getter': lambda recs: len([r for r in recs if r.optional]),
'value_getter2': lambda recs: time_format(sum([r.time_budget_mins or 0.
for r in recs if r.optional])),
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER'),
('LINEAFTER', (col_index, 0), (col_index, -1), .5, colors.gray)],
'width': num_column_width
})
columns.append({
'heading': 'Eff',
'value_getter': lambda recs: len([r for r in recs if r.effort]),
'value_getter2': lambda recs: time_format(sum([r.time_budget_mins or 0.
for r in recs if r.effort])),
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER')],
'width': num_column_width
})
if include_omitted:
columns.append({
'heading': 'Omit',
@@ -133,7 +144,6 @@ def build_columns(lines: List[ADRLine], reel_list: Optional[List[str]], show_pri
def populate_columns(lines: List[ADRLine], columns, include_omitted, _page_size):
# TODO: use page_size parameter
data = list()
styles = list()
columns_widths = list()
@@ -199,7 +209,7 @@ def output_report(lines: List[ADRLine], reel_list: List[str], include_omitted=Fa
style.append(('FONTNAME', (0, 0), (-1, -1), "Futura"))
style.append(('FONTSIZE', (0, 0), (-1, -1), 9.))
style.append(('LINEBELOW', (0, 0), (-1, 0), 1.0, colors.black))
style.append(('LINEBELOW', (0, 1), (-1, -1), 0.25, colors.gray))
# style.append(('LINEBELOW', (0, 1), (-1, -1), 0.25, colors.gray))
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
@@ -207,7 +217,7 @@ def output_report(lines: List[ADRLine], reel_list: List[str], include_omitted=Fa
filename = title + '.pdf'
doc = make_doc_template(page_size=page_size, filename=filename,
document_title=title, title=lines[0].title,
document_date=lines[0].spot,
document_subheader=lines[0].spot,
client=lines[0].client,
supervisor=lines[0].supervisor,
document_header='Line Count')
@@ -217,7 +227,7 @@ def output_report(lines: List[ADRLine], reel_list: List[str], include_omitted=Fa
table = Table(data=data, style=style, colWidths=columns_widths)
story = [table]
story = [Spacer(height=0.5 * inch, width=1.), table]
style = getSampleStyleSheet()['Normal']
style.fontName = 'Futura'
@@ -225,7 +235,9 @@ def output_report(lines: List[ADRLine], reel_list: List[str], include_omitted=Fa
style.spaceBefore = 16.
style.spaceAfter = 16.
if not include_omitted:
story.append(Paragraph("* Omitted lines are excluded.", style))
omitted_count = len([x for x in lines if x.omitted])
if not include_omitted and omitted_count > 0:
story.append(Paragraph("* %i Omitted lines are excluded." % omitted_count, style))
doc.build(story)

View File

@@ -130,7 +130,7 @@ def generate_report(page_size, lines: List[ADRLine], tc_rate: TimecodeFormat, ch
title=lines[0].title,
supervisor=lines[0].supervisor,
client=lines[0].client,
document_date=lines[0].spot,
document_subheader=lines[0].spot,
left_margin=0.75 * inch)
story = build_story(lines, tc_rate)
doc.build(story)

View File

@@ -31,7 +31,7 @@ def output_report(lines: List[ADRLine], tc_display_format: TimecodeFormat):
doc = make_doc_template(page_size=letter, filename=filename, document_title=title,
title=char_lines[0].title,
document_date=char_lines[0].spot,
document_subheader=char_lines[0].spot,
supervisor=char_lines[0].supervisor,
client=char_lines[0].client,
document_header=character_name)