From be92cbe884e50b76afb2ca9f401b1b07f65f7ac9 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Thu, 20 May 2021 18:11:58 -0700 Subject: [PATCH] Style --- ptulsconv/commands.py | 4 ++-- ptulsconv/pdf/line_count.py | 36 ++++++++++++++++----------------- ptulsconv/pdf/summary_log.py | 13 +++++------- ptulsconv/pdf/supervisor_1pg.py | 2 ++ ptulsconv/pdf/talent_sides.py | 4 ---- 5 files changed, 26 insertions(+), 33 deletions(-) diff --git a/ptulsconv/commands.py b/ptulsconv/commands.py index 7fb0d22..2c2297b 100644 --- a/ptulsconv/commands.py +++ b/ptulsconv/commands.py @@ -87,7 +87,7 @@ def normalize_record_keys(records): def convert(input_file, output_format='fmpxml', start=None, end=None, select_reel=None, progress=False, include_muted=False, xsl=None, - output=sys.stdout, log_output=sys.stderr, warnings=True, spelling=False): + output=sys.stdout, log_output=sys.stderr, warnings=True): with open(input_file, 'r') as file: print_section_header_style('Parsing') ast = ptulsconv.protools_text_export_grammar.parse(file.read()) @@ -160,5 +160,5 @@ def convert(input_file, output_format='fmpxml', start=None, end=None, select_ree fmp_dump(parsed, input_file, output, adr_field_map) else: print_section_header_style("Performing XSL Translation") - print_status_style("Using builtin translation: %s" % (xsl)) + print_status_style("Using builtin translation: %s" % xsl) fmp_transformed_dump(parsed, input_file, xsl, output) diff --git a/ptulsconv/pdf/line_count.py b/ptulsconv/pdf/line_count.py index 46f5018..8bca968 100644 --- a/ptulsconv/pdf/line_count.py +++ b/ptulsconv/pdf/line_count.py @@ -1,30 +1,25 @@ -from reportlab.pdfgen.canvas import Canvas - from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from reportlab.lib.units import inch -from reportlab.lib.pagesizes import letter, landscape, portrait +from reportlab.lib.pagesizes import letter, portrait from reportlab.lib import colors -from reportlab.lib.styles import getSampleStyleSheet -from reportlab.platypus import Paragraph, Table, TableStyle +from reportlab.platypus import Table -from .common import GRect, time_format, ReportCanvas, make_doc_template - -import datetime +from .common import time_format, make_doc_template -def build_columns(records, show_priorities = False): +def build_columns(records, show_priorities=False): columns = list() reel_numbers = sorted(set([x.get('Reel', None) for x in records['events'] if 'Reel' in x.keys()])) - def blank_len(iter): - l = len(iter) - if l == 0: + def blank_len(i): + length = len(i) + if length == 0: return "" else: - return str(l) + return str(length) num_column_width = 0.375 * inch @@ -53,7 +48,7 @@ def build_columns(records, show_priorities = False): # 'width': 1.75 * inch # }) - if True: #len(reel_numbers) > 0: + if len(reel_numbers) > 0: columns.append({ 'heading': 'RX', 'value_getter': lambda recs: blank_len([r for r in recs if r.get('Reel', None) in ("", None)]), @@ -96,17 +91,19 @@ def build_columns(records, show_priorities = False): columns.append({ 'heading': 'TV', 'value_getter': lambda recs: blank_len([r for r in recs if 'TV' in r.keys()]), - 'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) for r in recs if 'TV' in r.keys()])), + 'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) + for r in recs if 'TV' in r.keys()])), '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),], + ('LINEAFTER', (col_index, 0), (col_index, -1), .5, colors.gray)], 'width': num_column_width }) columns.append({ 'heading': 'Opt', 'value_getter': lambda recs: blank_len([r for r in recs if 'Optional' in r.keys()]), - 'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) for r in recs if 'Optional' in r.keys()])), + 'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) + for r in recs if 'Optional' in r.keys()])), '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 @@ -115,7 +112,8 @@ def build_columns(records, show_priorities = False): # columns.append({ # 'heading': 'Eff', # 'value_getter': lambda recs: blank_len([r for r in recs if 'Effort' in r.keys()]), - # 'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins',0.) for r in recs if 'Effort' in r.keys()])), + # 'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins',0.) + # for r in recs if 'Effort' in r.keys()])), # 'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER')], # 'width': 0.5 * inch # }) @@ -204,7 +202,7 @@ def populate_columns(records, columns): def output_report(records): columns = build_columns(records) data, style, columns_widths = populate_columns(records, columns) - style.append(('FONTNAME', [0, 0], (-1, -1), "Futura")) + 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)) diff --git a/ptulsconv/pdf/summary_log.py b/ptulsconv/pdf/summary_log.py index 6e25abc..4d5df93 100644 --- a/ptulsconv/pdf/summary_log.py +++ b/ptulsconv/pdf/summary_log.py @@ -1,17 +1,13 @@ # -*- coding: utf-8 -*- -from .common import GRect, draw_header_footer, time_format, make_doc_template +from .common import time_format, make_doc_template from reportlab.lib.units import inch -from reportlab.lib.pagesizes import letter, landscape, portrait +from reportlab.lib.pagesizes import letter, portrait -from reportlab.platypus import BaseDocTemplate, Paragraph, Spacer, \ - KeepTogether, Table, HRFlowable, PageTemplate, Frame +from reportlab.platypus import Paragraph, Spacer, KeepTogether, Table from reportlab.lib.styles import getSampleStyleSheet from reportlab.lib import colors -from reportlab.pdfbase import pdfmetrics -from reportlab.pdfbase.ttfonts import TTFont - def build_aux_data_field(line): entries = list() @@ -80,7 +76,8 @@ def build_story(lines): Paragraph("" + this_scene + "", scene_style), line_table])) else: - line_table.setStyle(table_style + [('LINEABOVE', (0, 0), (-1,0), .5, colors.gray)]) + table_style.append(('LINEABOVE', (0, 0), (-1, 0), .5, colors.gray)) + line_table.setStyle(table_style) story.append(KeepTogether([line_table])) return story diff --git a/ptulsconv/pdf/supervisor_1pg.py b/ptulsconv/pdf/supervisor_1pg.py index fca1504..9074b68 100644 --- a/ptulsconv/pdf/supervisor_1pg.py +++ b/ptulsconv/pdf/supervisor_1pg.py @@ -17,6 +17,7 @@ import datetime def draw_header_block(canvas, rect, record): rect.draw_text_cell(canvas, record['Cue Number'], "Helvetica", 44, vertical_align='m') + def draw_character_row(canvas, rect, record): label_frame, value_frame = rect.split_x(1.25 * inch) label_frame.draw_text_cell(canvas, "CHARACTER", "Futura", 10, force_baseline=9.) @@ -216,6 +217,7 @@ def create_report_for_character(records, report_date): draw_header_block(c, cue_header_block, record) # FIXME: Draw the title # TODO: Integrate this report into the common DocTemplate api + #draw_title_box(c, title_header_block, record) draw_character_row(c, char_row, record) draw_cue_number_block(c, cue_number_block, record) diff --git a/ptulsconv/pdf/talent_sides.py b/ptulsconv/pdf/talent_sides.py index a3e8b7e..37e4f22 100644 --- a/ptulsconv/pdf/talent_sides.py +++ b/ptulsconv/pdf/talent_sides.py @@ -10,10 +10,6 @@ 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):