mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2026-01-02 09:50:48 +00:00
Line Count enhancements
This commit is contained in:
@@ -53,6 +53,7 @@ adr_field_map = ((['Title', 'PT.Session.Name'], 'Title', str),
|
|||||||
(['Movie.Start_Offset_Seconds'], 'Movie Seconds', float),
|
(['Movie.Start_Offset_Seconds'], 'Movie Seconds', float),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def dump_field_map(field_map_name, output=sys.stdout):
|
def dump_field_map(field_map_name, output=sys.stdout):
|
||||||
output.write("# Map of Tag fields to XML output columns\n")
|
output.write("# Map of Tag fields to XML output columns\n")
|
||||||
output.write("# (in order of precedence)\n")
|
output.write("# (in order of precedence)\n")
|
||||||
@@ -70,6 +71,7 @@ def dump_field_map(field_map_name, output=sys.stdout):
|
|||||||
for tag in field[0]:
|
for tag in field[0]:
|
||||||
output.write("# %-27s-> %-20s | %-8s| %-7i\n" % (tag[:27], field[1][:20], field[2].__name__, n + 1))
|
output.write("# %-27s-> %-20s | %-8s| %-7i\n" % (tag[:27], field[1][:20], field[2].__name__, n + 1))
|
||||||
|
|
||||||
|
|
||||||
def normalize_record_keys(records):
|
def normalize_record_keys(records):
|
||||||
for record in records['events']:
|
for record in records['events']:
|
||||||
for field in adr_field_map:
|
for field in adr_field_map:
|
||||||
|
|||||||
@@ -75,8 +75,10 @@ def make_doc_template(page_size, filename, document_title, record, document_head
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def time_format(mins):
|
def time_format(mins, zero_str = ""):
|
||||||
if mins < 60.:
|
if mins == 0. and zero_str is not None:
|
||||||
|
return zero_str
|
||||||
|
elif mins < 60.:
|
||||||
return "%im" % round(mins)
|
return "%im" % round(mins)
|
||||||
else:
|
else:
|
||||||
m = round(mins)
|
m = round(mins)
|
||||||
|
|||||||
@@ -26,41 +26,51 @@ def build_columns(records, show_priorities = False):
|
|||||||
else:
|
else:
|
||||||
return str(l)
|
return str(l)
|
||||||
|
|
||||||
|
num_column_width = 0.375 * inch
|
||||||
|
|
||||||
columns.append({
|
columns.append({
|
||||||
'heading': '#',
|
'heading': '#',
|
||||||
'value_getter': lambda recs: recs[0]['Character Number'],
|
'value_getter': lambda recs: recs[0]['Character Number'],
|
||||||
|
'value_getter2': lambda recs: "",
|
||||||
'style_getter': lambda col_index: [],
|
'style_getter': lambda col_index: [],
|
||||||
'width': 0.75 * inch
|
'width': 0.375 * inch,
|
||||||
|
'summarize': False
|
||||||
})
|
})
|
||||||
|
|
||||||
columns.append({
|
columns.append({
|
||||||
'heading': 'Role',
|
'heading': 'Role',
|
||||||
'value_getter': lambda recs: recs[0]['Character Name'],
|
'value_getter': lambda recs: recs[0]['Character Name'],
|
||||||
'style_getter': lambda col_index: [],
|
'value_getter2': lambda recs: recs[0].get('Actor Name', ""),
|
||||||
'width': 1.75 * inch
|
'style_getter': lambda col_index: [('LINEAFTER', (col_index, 0), (col_index, -1), 1.0, colors.black)],
|
||||||
|
'width': 1.75 * inch,
|
||||||
|
'summarize': False
|
||||||
})
|
})
|
||||||
|
|
||||||
columns.append({
|
# columns.append({
|
||||||
'heading': 'Actor',
|
# 'heading': 'Actor',
|
||||||
'value_getter': lambda recs: recs[0].get('Actor Name', ''),
|
# 'value_getter': lambda recs: recs[0].get('Actor Name', ''),
|
||||||
'style_getter': lambda col_index: [(('LINEAFTER'), (col_index, 0), (col_index, -1), 1.0, colors.black)],
|
# 'style_getter': lambda col_index: [(('LINEAFTER'), (col_index, 0), (col_index, -1), 1.0, colors.black)],
|
||||||
'width': 1.75 * inch
|
# 'width': 1.75 * inch
|
||||||
})
|
# })
|
||||||
|
|
||||||
if len(reel_numbers) > 0:
|
if True: #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)]),
|
||||||
'style_getter': lambda col_index: [],
|
'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) for r in recs
|
||||||
'width': 0.5 * inch
|
if r.get('Reel', None) in ("", None)])),
|
||||||
|
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER')],
|
||||||
|
'width': num_column_width
|
||||||
})
|
})
|
||||||
|
|
||||||
for n in reel_numbers:
|
for n in reel_numbers:
|
||||||
columns.append({
|
columns.append({
|
||||||
'heading': n,
|
'heading': n,
|
||||||
'value_getter': lambda recs: blank_len([r for r in recs if r['Reel'] == n]),
|
'value_getter': lambda recs: blank_len([r for r in recs if r['Reel'] == n]),
|
||||||
'style_getter': lambda col_index: [],
|
'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) for r in recs
|
||||||
'width': 0.5 * inch
|
if r['Reel'] == n])),
|
||||||
|
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER')],
|
||||||
|
'width': num_column_width
|
||||||
})
|
})
|
||||||
|
|
||||||
if show_priorities:
|
if show_priorities:
|
||||||
@@ -68,52 +78,64 @@ def build_columns(records, show_priorities = False):
|
|||||||
columns.append({
|
columns.append({
|
||||||
'heading': 'P%i' % n,
|
'heading': 'P%i' % n,
|
||||||
'value_getter': lambda recs: blank_len([r for r in recs if r.get('Priority', None) == n]),
|
'value_getter': lambda recs: blank_len([r for r in recs if r.get('Priority', None) == n]),
|
||||||
|
'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.)
|
||||||
|
for r in recs if r.get('Priority', None) == n])),
|
||||||
'style_getter': lambda col_index: [],
|
'style_getter': lambda col_index: [],
|
||||||
'width': 0.375 * inch
|
'width': num_column_width
|
||||||
})
|
})
|
||||||
|
|
||||||
columns.append({
|
columns.append({
|
||||||
'heading': '>P5',
|
'heading': '>P5',
|
||||||
'value_getter': lambda recs: blank_len([r for r in recs if r.get('Priority', 5) > 5]),
|
'value_getter': lambda recs: blank_len([r for r in recs if r.get('Priority', 5) > 5]),
|
||||||
|
'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.)
|
||||||
|
for r in recs if r.get('Priority', 5) > 5])),
|
||||||
'style_getter': lambda col_index: [],
|
'style_getter': lambda col_index: [],
|
||||||
'width': 0.375 * inch
|
'width': num_column_width
|
||||||
})
|
})
|
||||||
|
|
||||||
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()]),
|
||||||
'style_getter': lambda col_index: [],
|
'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) for r in recs if 'TV' in r.keys()])),
|
||||||
'width': 0.375 * inch
|
'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({
|
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()]),
|
||||||
'style_getter': lambda col_index: [],
|
'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) for r in recs if 'Optional' in r.keys()])),
|
||||||
'width': 0.375 * inch
|
'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({
|
# 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()]),
|
||||||
'style_getter': lambda col_index: [],
|
# 'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins',0.) for r in recs if 'Effort' in r.keys()])),
|
||||||
'width': 0.375 * inch
|
# 'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'CENTER')],
|
||||||
})
|
# 'width': 0.5 * inch
|
||||||
|
# })
|
||||||
|
|
||||||
columns.append({
|
columns.append({
|
||||||
'heading': 'Total',
|
'heading': 'Total',
|
||||||
'value_getter': lambda recs: len([r for r in recs if 'Omitted' not in r.keys()]),
|
'value_getter': lambda recs: len([r for r in recs if 'Omitted' not in r.keys()]),
|
||||||
'style_getter': lambda col_index: [(('LINEBEFORE'), (col_index, 0), (col_index, -1), 1.0, colors.black),
|
'value_getter2': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.)
|
||||||
('ALIGN', (col_index, 0), (col_index, -1), 'RIGHT')],
|
for r in recs if 'Omitted' not in r.keys()]), zero_str=None),
|
||||||
'width': 0.5 * inch
|
'style_getter': lambda col_index: [('LINEBEFORE', (col_index, 0), (col_index, -1), 1.0, colors.black),
|
||||||
|
('ALIGN', (col_index, 0), (col_index, -1), 'CENTER')],
|
||||||
|
'width': num_column_width
|
||||||
})
|
})
|
||||||
|
|
||||||
columns.append({
|
# columns.append({
|
||||||
'heading': 'Studio Time',
|
# 'heading': 'Studio Time',
|
||||||
'value_getter': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) for r in recs])),
|
# 'value_getter': lambda recs: time_format(sum([r.get('Time Budget Mins', 0.) for r in recs])),
|
||||||
'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'RIGHT')],
|
# 'style_getter': lambda col_index: [('ALIGN', (col_index, 0), (col_index, -1), 'RIGHT')],
|
||||||
'width': inch
|
# 'width': inch
|
||||||
})
|
# })
|
||||||
|
|
||||||
# columns.append({
|
# columns.append({
|
||||||
# 'heading': 'Omit',
|
# 'heading': 'Omit',
|
||||||
@@ -139,19 +161,42 @@ def populate_columns(records, columns):
|
|||||||
styles.extend(c['style_getter'](i))
|
styles.extend(c['style_getter'](i))
|
||||||
columns_widths.append(c['width'])
|
columns_widths.append(c['width'])
|
||||||
|
|
||||||
# construct data table
|
|
||||||
# headers
|
|
||||||
data.append(list(map(lambda x: x['heading'], columns)))
|
data.append(list(map(lambda x: x['heading'], columns)))
|
||||||
|
|
||||||
# values
|
lines = [x for x in records['events'] if 'Omitted' not in x.keys()]
|
||||||
|
|
||||||
for n in sorted_character_numbers:
|
for n in sorted_character_numbers:
|
||||||
char_records = sorted([x for x in records['events'] if x['Character Number'] == n],
|
char_records = sorted([x for x in lines if x['Character Number'] == n],
|
||||||
key=lambda x: x['PT.Clip.Start_Seconds'])
|
key=lambda x: x['PT.Clip.Start_Seconds'])
|
||||||
row_data = list()
|
row_data = list()
|
||||||
|
row_data2 = list()
|
||||||
for col in columns:
|
for col in columns:
|
||||||
|
row1_index = len(data)
|
||||||
|
row2_index = row1_index + 1
|
||||||
row_data.append(col['value_getter'](char_records))
|
row_data.append(col['value_getter'](char_records))
|
||||||
|
row_data2.append(col['value_getter2'](char_records))
|
||||||
|
styles.extend([('TEXTCOLOR', (0, row2_index), (-1, row2_index), colors.red),
|
||||||
|
('LINEBELOW', (0, row2_index), (-1, row2_index), 0.5, colors.black)])
|
||||||
|
|
||||||
data.append(row_data)
|
data.append(row_data)
|
||||||
|
data.append(row_data2)
|
||||||
|
|
||||||
|
summary_row1 = list()
|
||||||
|
summary_row2 = list()
|
||||||
|
row1_index = len(data)
|
||||||
|
|
||||||
|
for col in columns:
|
||||||
|
if col.get('summarize', True):
|
||||||
|
summary_row1.append(col['value_getter'](lines))
|
||||||
|
summary_row2.append(col['value_getter2'](lines))
|
||||||
|
else:
|
||||||
|
summary_row1.append("")
|
||||||
|
summary_row2.append("")
|
||||||
|
|
||||||
|
styles.append(('LINEABOVE', (0, row1_index), (-1, row1_index), 2.0, colors.black))
|
||||||
|
|
||||||
|
data.append(summary_row1)
|
||||||
|
data.append(summary_row2)
|
||||||
|
|
||||||
return data, styles, columns_widths
|
return data, styles, columns_widths
|
||||||
|
|
||||||
@@ -160,7 +205,7 @@ 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), 11))
|
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))
|
||||||
|
|
||||||
@@ -172,22 +217,6 @@ def output_report(records):
|
|||||||
document_title=title,
|
document_title=title,
|
||||||
record=records['events'][0], document_header='Line Count')
|
record=records['events'][0], document_header='Line Count')
|
||||||
|
|
||||||
# page: GRect = GRect(0, 0, letter[1], letter[0])
|
|
||||||
# page = page.inset(inch * 0.5)
|
|
||||||
# title_box, table_box = page.split_y(inch, 'd')
|
|
||||||
#
|
|
||||||
# c = ReportCanvas('%s Line Count.pdf' % records['events'][0]['Title'], pagesize=(letter[1], letter[0]))
|
|
||||||
# c.setFont('Futura', 18.)
|
|
||||||
# c.drawCentredString(title_box.center_x, title_box.center_y, "Line Count")
|
|
||||||
#
|
|
||||||
table = Table(data=data, style=style, colWidths=columns_widths)
|
table = Table(data=data, style=style, colWidths=columns_widths)
|
||||||
#
|
|
||||||
# w, h = table.wrap(table_box.width, table_box.height)
|
|
||||||
# table.drawOn(canvas=c,
|
|
||||||
# x=table_box.min_x + table_box.width / 2. - w / 2.,
|
|
||||||
# y=table_box.max_y - h)
|
|
||||||
|
|
||||||
doc.build([table])
|
doc.build([table])
|
||||||
|
|
||||||
# c.showPage()
|
|
||||||
# c.save()
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ def build_story(lines):
|
|||||||
scene_style = getSampleStyleSheet()['Normal']
|
scene_style = getSampleStyleSheet()['Normal']
|
||||||
scene_style.fontName = 'Futura'
|
scene_style.fontName = 'Futura'
|
||||||
scene_style.leftIndent = 0.
|
scene_style.leftIndent = 0.
|
||||||
|
scene_style.leftPadding = 0.
|
||||||
line_style = getSampleStyleSheet()['Normal']
|
line_style = getSampleStyleSheet()['Normal']
|
||||||
line_style.fontName = 'Futura'
|
line_style.fontName = 'Futura'
|
||||||
|
|
||||||
|
|||||||
@@ -59,8 +59,9 @@ def output_report(records):
|
|||||||
# Unicode: U+2192, UTF-8: E2 86 92
|
# Unicode: U+2192, UTF-8: E2 86 92
|
||||||
story.append(
|
story.append(
|
||||||
KeepTogether(
|
KeepTogether(
|
||||||
[HRFlowable(width='100%', color=colors.black),
|
[HRFlowable(width='50%', color=colors.black),
|
||||||
Table(data=data_block, colWidths=[1.5 * inch, 6. * inch]),
|
Table(data=data_block, colWidths=[1.5 * inch, 6. * inch],
|
||||||
|
style=[('LEFTPADDING', (0, 0), (-1, -1), 0.)]),
|
||||||
Paragraph(line['Line'], prompt_style),
|
Paragraph(line['Line'], prompt_style),
|
||||||
Spacer(1., inch * 1.5)]
|
Spacer(1., inch * 1.5)]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user