mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Reworked function calls to report functions
To make things make more sense.
This commit is contained in:
@@ -143,31 +143,34 @@ def convert(input_file, output_format='fmpxml', start=None, end=None, select_ree
|
||||
if output_format == 'json':
|
||||
json.dump(parsed, output)
|
||||
|
||||
elif output_format == 'full':
|
||||
elif output_format == 'adr':
|
||||
|
||||
lines = [e for e in parsed['events'] if 'ADR' in e.keys()]
|
||||
|
||||
print_section_header_style("Creating PDF Reports")
|
||||
|
||||
print_status_style("Creating ADR Report")
|
||||
output_summary(parsed)
|
||||
output_summary(lines)
|
||||
|
||||
print_status_style("Creating Line Count")
|
||||
output_line_count(parsed)
|
||||
output_line_count(lines)
|
||||
|
||||
print_status_style("Creating Supervisor Logs directory and reports")
|
||||
os.makedirs("Supervisor Logs", exist_ok=True)
|
||||
os.chdir("Supervisor Logs")
|
||||
output_supervisor_1pg(parsed)
|
||||
output_supervisor_1pg(lines)
|
||||
|
||||
os.chdir("..")
|
||||
print_status_style("Creating Director's Logs director and reports")
|
||||
os.makedirs("Director Logs", exist_ok=True)
|
||||
os.chdir("Director Logs")
|
||||
output_summary(parsed, by_character=True)
|
||||
output_summary(lines, by_character=True)
|
||||
|
||||
os.chdir("..")
|
||||
print_status_style("Creating Scripts directory and reports")
|
||||
os.makedirs("Talent Scripts", exist_ok=True)
|
||||
os.chdir("Talent Scripts")
|
||||
output_talent_sides(parsed)
|
||||
output_talent_sides(lines)
|
||||
|
||||
elif output_format == 'fmpxml':
|
||||
if xsl is None:
|
||||
|
||||
@@ -11,9 +11,9 @@ from reportlab.lib.styles import getSampleStyleSheet
|
||||
from .common import time_format, make_doc_template
|
||||
|
||||
|
||||
def build_columns(records, show_priorities=False, include_omitted=False):
|
||||
def build_columns(lines, show_priorities=False, include_omitted=False):
|
||||
columns = list()
|
||||
reel_numbers = sorted(set([x['Reel'] for x in records['events'] if 'Reel' in x.keys()]))
|
||||
reel_numbers = sorted(set([x['Reel'] for x in lines if 'Reel' in x.keys()]))
|
||||
|
||||
num_column_width = 0.375 * inch
|
||||
|
||||
@@ -129,12 +129,12 @@ def build_columns(records, show_priorities=False, include_omitted=False):
|
||||
return columns
|
||||
|
||||
|
||||
def populate_columns(records, columns, include_omitted, page_size):
|
||||
def populate_columns(lines, columns, include_omitted, page_size):
|
||||
data = list()
|
||||
styles = list()
|
||||
columns_widths = list()
|
||||
|
||||
sorted_character_numbers = sorted(set([x['Character Number'] for x in records['events']
|
||||
sorted_character_numbers = sorted(set([x['Character Number'] for x in lines
|
||||
if 'Character Number' in x.keys()]),
|
||||
key=lambda x: str(x))
|
||||
|
||||
@@ -146,10 +146,8 @@ def populate_columns(records, columns, include_omitted, page_size):
|
||||
|
||||
data.append(list(map(lambda x: x['heading'], columns)))
|
||||
|
||||
if include_omitted:
|
||||
lines = [x for x in records['events']]
|
||||
else:
|
||||
lines = [x for x in records['events'] if 'Omitted' not in x.keys()]
|
||||
if not include_omitted:
|
||||
lines = [x for x in lines if 'Omitted' not in x.keys()]
|
||||
|
||||
for n in sorted_character_numbers:
|
||||
char_records = list([x for x in lines if x['Character Number'] == n])
|
||||
@@ -189,9 +187,9 @@ def populate_columns(records, columns, include_omitted, page_size):
|
||||
def build_header(column_widths):
|
||||
pass
|
||||
|
||||
def output_report(records, include_omitted=False, page_size=portrait(letter)):
|
||||
columns = build_columns(records, include_omitted)
|
||||
data, style, columns_widths = populate_columns(records, columns, include_omitted, page_size)
|
||||
def output_report(lines, include_omitted=False, page_size=portrait(letter)):
|
||||
columns = build_columns(lines, include_omitted)
|
||||
data, style, columns_widths = populate_columns(lines, columns, include_omitted, page_size)
|
||||
|
||||
style.append(('FONTNAME', (0, 0), (-1, -1), "Futura"))
|
||||
style.append(('FONTSIZE', (0, 0), (-1, -1), 9.))
|
||||
@@ -200,11 +198,11 @@ def output_report(records, include_omitted=False, page_size=portrait(letter)):
|
||||
|
||||
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
||||
|
||||
title = "%s Line Count" % (records['events'][0]['Title'])
|
||||
title = "%s Line Count" % (lines[0]['Title'])
|
||||
filename = title + '.pdf'
|
||||
doc = make_doc_template(page_size=page_size, filename=filename,
|
||||
document_title=title,
|
||||
record=records['events'][0],
|
||||
record=lines[0],
|
||||
document_header='Line Count')
|
||||
|
||||
#header_data, header_style, header_widths = build_header(columns_widths)
|
||||
|
||||
@@ -56,16 +56,7 @@ def build_story(lines):
|
||||
('LEFTPADDING', (0, 0), (0, 0), 0.0),
|
||||
('BOTTOMPADDING', (0, 0), (-1, -1), 24.)]
|
||||
|
||||
# if 'Omitted' in line.keys():
|
||||
# cue_number_field = "<s>" + line['Cue Number'] + "</s><br /><font fontSize=7>" + \
|
||||
# line['Character Name'] + "</font>"
|
||||
# table_style.append(('BACKGROUND', (0, 0), (-1, 0), colors.lightpink))
|
||||
# elif 'Effort' in line.keys():
|
||||
# cue_number_field = "<s>" + line['Cue Number'] + "</s><br /><font fontSize=7>" + \
|
||||
# line['Character Name'] + "</font>"
|
||||
# table_style.append(('BACKGROUND', (0, 0), (-1, 0), colors.lightgreen))
|
||||
# else:
|
||||
cue_number_field = line['Cue Number'] + "<br /><font fontSize=7>" + line['Character Name'] + "</font>"
|
||||
cue_number_field = "%s<br /><font fontSize=7>%s</font>" % (line['Cue Number'], line['Character Name'])
|
||||
|
||||
time_data = time_format(line.get('Time Budget Mins', 0.))
|
||||
|
||||
@@ -74,19 +65,7 @@ def build_story(lines):
|
||||
|
||||
aux_data_field = build_aux_data_field(line)
|
||||
|
||||
tc_data = line['PT.Clip.Start'] + "<br />" + line['PT.Clip.Finish']
|
||||
|
||||
third_line = []
|
||||
if 'Reel' in line.keys():
|
||||
if line['Reel'][0:1] == 'R':
|
||||
third_line.append("%s" % (line['Reel']))
|
||||
else:
|
||||
third_line.append("Reel %s" % (line['Reel']))
|
||||
if 'Version' in line.keys():
|
||||
third_line.append("(%s)" % line['Version'])
|
||||
|
||||
if len(third_line) > 0:
|
||||
tc_data = tc_data + "<br/>" + " ".join(third_line)
|
||||
tc_data = build_tc_data(line)
|
||||
|
||||
line_table_data = [[Paragraph(cue_number_field, line_style),
|
||||
Paragraph(tc_data, line_style),
|
||||
@@ -112,8 +91,23 @@ def build_story(lines):
|
||||
return story
|
||||
|
||||
|
||||
def generate_report(page_size, records, character_number=None):
|
||||
lines = records['events']
|
||||
def build_tc_data(line):
|
||||
tc_data = line['PT.Clip.Start'] + "<br />" + line['PT.Clip.Finish']
|
||||
third_line = []
|
||||
if 'Reel' in line.keys():
|
||||
if line['Reel'][0:1] == 'R':
|
||||
third_line.append("%s" % (line['Reel']))
|
||||
else:
|
||||
third_line.append("Reel %s" % (line['Reel']))
|
||||
if 'Version' in line.keys():
|
||||
third_line.append("(%s)" % line['Version'])
|
||||
if len(third_line) > 0:
|
||||
tc_data = tc_data + "<br/>" + " ".join(third_line)
|
||||
return tc_data
|
||||
|
||||
|
||||
def generate_report(page_size, lines, character_number=None, include_done=True,
|
||||
include_omitted=True):
|
||||
if character_number is not None:
|
||||
lines = [r for r in lines if r['Character Number'] == character_number]
|
||||
title = "%s ADR Report (%s)" % (lines[0]['Title'], lines[0]['Character Name'])
|
||||
@@ -122,6 +116,12 @@ def generate_report(page_size, records, character_number=None):
|
||||
title = "%s ADR Report" % (lines[0]['Title'])
|
||||
document_header = 'ADR Report'
|
||||
|
||||
if not include_done:
|
||||
lines = [line for line in lines if 'Done' not in line.keys()]
|
||||
|
||||
if not include_omitted:
|
||||
lines = [line for line in lines if 'Omitted' not in line.keys()]
|
||||
|
||||
lines = sorted(lines, key=lambda line: line['PT.Clip.Start_Seconds'])
|
||||
|
||||
filename = title + ".pdf"
|
||||
@@ -132,10 +132,10 @@ def generate_report(page_size, records, character_number=None):
|
||||
doc.build(story)
|
||||
|
||||
|
||||
def output_report(records, page_size=portrait(letter), by_character=False):
|
||||
def output_report(lines, page_size=portrait(letter), by_character=False):
|
||||
if by_character:
|
||||
character_numbers = set((r['Character Number'] for r in records['events']))
|
||||
character_numbers = set((r['Character Number'] for r in lines))
|
||||
for n in character_numbers:
|
||||
generate_report(page_size, records, n)
|
||||
generate_report(page_size, lines, n)
|
||||
else:
|
||||
generate_report(page_size, records)
|
||||
generate_report(page_size, lines)
|
||||
|
||||
@@ -236,10 +236,10 @@ def create_report_for_character(records, report_date):
|
||||
c.save()
|
||||
|
||||
|
||||
def output_report(records):
|
||||
def output_report(lines):
|
||||
report_date = datetime.datetime.now()
|
||||
events = sorted(records['events'], key=lambda x: x['PT.Clip.Start_Frames'])
|
||||
character_numbers = set([x['CN'] for x in events])
|
||||
events = sorted(lines, key=lambda x: x['PT.Clip.Start_Frames'])
|
||||
character_numbers = set([x['CN'] for x in lines])
|
||||
|
||||
for n in character_numbers:
|
||||
create_report_for_character([e for e in events if e['CN'] == n], report_date)
|
||||
|
||||
@@ -12,21 +12,21 @@ from reportlab.pdfbase import pdfmetrics
|
||||
from reportlab.pdfbase.ttfonts import TTFont
|
||||
|
||||
|
||||
def output_report(records):
|
||||
character_numbers = set([n['Character Number'] for n in records['events']])
|
||||
def output_report(lines):
|
||||
character_numbers = set([n['Character Number'] for n in lines])
|
||||
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
||||
|
||||
for n in character_numbers:
|
||||
lines = [line for line in records['events']
|
||||
char_lines = [line for line in lines
|
||||
if 'Omit' not in line.keys() and line['Character Number'] == n]
|
||||
|
||||
sorted(lines, key=lambda line: line['PT.Clip.Start_Seconds'])
|
||||
sorted(char_lines, key=lambda line: line['PT.Clip.Start_Seconds'])
|
||||
|
||||
title = "%s (%s) %s ADR Script" % (lines[0]['Title'], lines[0]['Character Name'], n)
|
||||
title = "%s (%s) %s ADR Script" % (char_lines[0]['Title'], char_lines[0]['Character Name'], n)
|
||||
filename = "%s_%s_%s_ADR Script.pdf" % (lines[0]['Title'], n, lines[0]['Character Name'])
|
||||
|
||||
doc = make_doc_template(page_size=letter, filename=filename, document_title=title,
|
||||
record=lines[0], document_header=lines[0]['Character Name'])
|
||||
record=char_lines[0], document_header=char_lines[0]['Character Name'])
|
||||
|
||||
story = []
|
||||
|
||||
@@ -46,7 +46,7 @@ def output_report(records):
|
||||
number_style.leftIndent = 0.
|
||||
number_style.rightIndent = 0.
|
||||
|
||||
for line in lines:
|
||||
for line in char_lines:
|
||||
data_block = [[Paragraph(line['Cue Number'], number_style),
|
||||
Paragraph(line['PT.Clip.Start'] + " - " + line['PT.Clip.Finish'], number_style)
|
||||
]]
|
||||
|
||||
Reference in New Issue
Block a user