mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 17:00:46 +00:00
Style
This commit is contained in:
@@ -87,7 +87,7 @@ def normalize_record_keys(records):
|
|||||||
|
|
||||||
def convert(input_file, output_format='fmpxml', start=None, end=None, select_reel=None,
|
def convert(input_file, output_format='fmpxml', start=None, end=None, select_reel=None,
|
||||||
progress=False, include_muted=False, xsl=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:
|
with open(input_file, 'r') as file:
|
||||||
print_section_header_style('Parsing')
|
print_section_header_style('Parsing')
|
||||||
ast = ptulsconv.protools_text_export_grammar.parse(file.read())
|
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)
|
fmp_dump(parsed, input_file, output, adr_field_map)
|
||||||
else:
|
else:
|
||||||
print_section_header_style("Performing XSL Translation")
|
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)
|
fmp_transformed_dump(parsed, input_file, xsl, output)
|
||||||
|
|||||||
@@ -1,30 +1,25 @@
|
|||||||
from reportlab.pdfgen.canvas import Canvas
|
|
||||||
|
|
||||||
from reportlab.pdfbase import pdfmetrics
|
from reportlab.pdfbase import pdfmetrics
|
||||||
from reportlab.pdfbase.ttfonts import TTFont
|
from reportlab.pdfbase.ttfonts import TTFont
|
||||||
|
|
||||||
from reportlab.lib.units import inch
|
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 import colors
|
||||||
|
|
||||||
from reportlab.lib.styles import getSampleStyleSheet
|
from reportlab.platypus import Table
|
||||||
from reportlab.platypus import Paragraph, Table, TableStyle
|
|
||||||
|
|
||||||
from .common import GRect, time_format, ReportCanvas, make_doc_template
|
from .common import time_format, make_doc_template
|
||||||
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
|
|
||||||
def build_columns(records, show_priorities = False):
|
def build_columns(records, show_priorities=False):
|
||||||
columns = list()
|
columns = list()
|
||||||
reel_numbers = sorted(set([x.get('Reel', None) for x in records['events'] if 'Reel' in x.keys()]))
|
reel_numbers = sorted(set([x.get('Reel', None) for x in records['events'] if 'Reel' in x.keys()]))
|
||||||
|
|
||||||
def blank_len(iter):
|
def blank_len(i):
|
||||||
l = len(iter)
|
length = len(i)
|
||||||
if l == 0:
|
if length == 0:
|
||||||
return ""
|
return ""
|
||||||
else:
|
else:
|
||||||
return str(l)
|
return str(length)
|
||||||
|
|
||||||
num_column_width = 0.375 * inch
|
num_column_width = 0.375 * inch
|
||||||
|
|
||||||
@@ -53,7 +48,7 @@ def build_columns(records, show_priorities = False):
|
|||||||
# 'width': 1.75 * inch
|
# 'width': 1.75 * inch
|
||||||
# })
|
# })
|
||||||
|
|
||||||
if True: #len(reel_numbers) > 0:
|
if len(reel_numbers) > 0:
|
||||||
columns.append({
|
columns.append({
|
||||||
'heading': 'RX',
|
'heading': 'RX',
|
||||||
'value_getter': lambda recs: blank_len([r for r in recs if r.get('Reel', None) in ("", None)]),
|
'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({
|
columns.append({
|
||||||
'heading': 'TV',
|
'heading': 'TV',
|
||||||
'value_getter': lambda recs: blank_len([r for r in recs if 'TV' in r.keys()]),
|
'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'),
|
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER'),
|
||||||
('LINEBEFORE', (col_index, 0), (col_index, -1), 1., colors.black),
|
('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
|
'width': num_column_width
|
||||||
})
|
})
|
||||||
|
|
||||||
columns.append({
|
columns.append({
|
||||||
'heading': 'Opt',
|
'heading': 'Opt',
|
||||||
'value_getter': lambda recs: blank_len([r for r in recs if 'Optional' in r.keys()]),
|
'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'),
|
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER'),
|
||||||
('LINEAFTER', (col_index, 0), (col_index, -1), .5, colors.gray)],
|
('LINEAFTER', (col_index, 0), (col_index, -1), .5, colors.gray)],
|
||||||
'width': num_column_width
|
'width': num_column_width
|
||||||
@@ -115,7 +112,8 @@ def build_columns(records, show_priorities = False):
|
|||||||
# columns.append({
|
# columns.append({
|
||||||
# 'heading': 'Eff',
|
# 'heading': 'Eff',
|
||||||
# 'value_getter': lambda recs: blank_len([r for r in recs if 'Effort' in r.keys()]),
|
# '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')],
|
# 'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER')],
|
||||||
# 'width': 0.5 * inch
|
# 'width': 0.5 * inch
|
||||||
# })
|
# })
|
||||||
@@ -204,7 +202,7 @@ def populate_columns(records, columns):
|
|||||||
def output_report(records):
|
def output_report(records):
|
||||||
columns = build_columns(records)
|
columns = build_columns(records)
|
||||||
data, style, columns_widths = populate_columns(records, columns)
|
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(('FONTSIZE', (0, 0), (-1, -1), 9.))
|
||||||
style.append(('LINEBELOW', (0, 0), (-1, 0), 1.0, colors.black))
|
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))
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- 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.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, \
|
from reportlab.platypus import Paragraph, Spacer, KeepTogether, Table
|
||||||
KeepTogether, Table, HRFlowable, PageTemplate, Frame
|
|
||||||
from reportlab.lib.styles import getSampleStyleSheet
|
from reportlab.lib.styles import getSampleStyleSheet
|
||||||
from reportlab.lib import colors
|
from reportlab.lib import colors
|
||||||
|
|
||||||
from reportlab.pdfbase import pdfmetrics
|
|
||||||
from reportlab.pdfbase.ttfonts import TTFont
|
|
||||||
|
|
||||||
|
|
||||||
def build_aux_data_field(line):
|
def build_aux_data_field(line):
|
||||||
entries = list()
|
entries = list()
|
||||||
@@ -80,7 +76,8 @@ def build_story(lines):
|
|||||||
Paragraph("<u>" + this_scene + "</u>", scene_style),
|
Paragraph("<u>" + this_scene + "</u>", scene_style),
|
||||||
line_table]))
|
line_table]))
|
||||||
else:
|
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]))
|
story.append(KeepTogether([line_table]))
|
||||||
|
|
||||||
return story
|
return story
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ 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_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.)
|
||||||
@@ -216,6 +217,7 @@ def create_report_for_character(records, report_date):
|
|||||||
draw_header_block(c, cue_header_block, record)
|
draw_header_block(c, cue_header_block, record)
|
||||||
# FIXME: Draw the title
|
# FIXME: Draw the title
|
||||||
# TODO: Integrate this report into the common DocTemplate api
|
# TODO: Integrate this report into the common DocTemplate api
|
||||||
|
|
||||||
#draw_title_box(c, title_header_block, record)
|
#draw_title_box(c, title_header_block, record)
|
||||||
draw_character_row(c, char_row, record)
|
draw_character_row(c, char_row, record)
|
||||||
draw_cue_number_block(c, cue_number_block, record)
|
draw_cue_number_block(c, cue_number_block, record)
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ from reportlab.lib import colors
|
|||||||
|
|
||||||
from reportlab.pdfbase import pdfmetrics
|
from reportlab.pdfbase import pdfmetrics
|
||||||
from reportlab.pdfbase.ttfonts import TTFont
|
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):
|
def output_report(records):
|
||||||
|
|||||||
Reference in New Issue
Block a user