Very rough implementation of line count

This commit is contained in:
Jamie Hardt
2021-05-17 23:04:38 -07:00
parent 8a067984eb
commit 2aca5a3e8f
4 changed files with 115 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
<dictionary name="jamie"> <dictionary name="jamie">
<words> <words>
<w>fmpxml</w> <w>fmpxml</w>
<w>futura</w>
<w>ptulsconv</w> <w>ptulsconv</w>
<w>timecode</w> <w>timecode</w>
<w>timespan</w> <w>timespan</w>

View File

@@ -13,6 +13,7 @@ from .reporting import print_section_header_style, print_status_style, print_war
from .validations import * from .validations import *
from ptulsconv.pdf.supervisor_1pg import output_report as output_supervisor_1pg from ptulsconv.pdf.supervisor_1pg import output_report as output_supervisor_1pg
from ptulsconv.pdf.line_count import output_report as output_line_count
# field_map maps tags in the text export to fields in FMPXMLRESULT # field_map maps tags in the text export to fields in FMPXMLRESULT
# - tuple field 0 is a list of tags, the first tag with contents will be used as source # - tuple field 0 is a list of tags, the first tag with contents will be used as source
@@ -217,7 +218,9 @@ def convert(input_file, output_format='fmpxml', start=None, end=None, select_ree
json.dump(normalize_record_keys(parsed), output) json.dump(normalize_record_keys(parsed), output)
elif output_format == 'full': elif output_format == 'full':
print("Sorry, the `full` output type is not yet supported.") print("Sorry, the `full` output type is not yet supported.")
output_supervisor_1pg(normalize_record_keys(parsed)) normalized_records = normalize_record_keys(parsed)
output_supervisor_1pg(normalized_records)
output_line_count(normalized_records)
elif output_format == 'fmpxml': elif output_format == 'fmpxml':
if xsl is None: if xsl is None:
fmp_dump(parsed, input_file, output) fmp_dump(parsed, input_file, output)

View File

@@ -0,0 +1,90 @@
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
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import Paragraph, Table, TableStyle
from .common import GRect
import datetime
def output_report(records):
# CN
# Role
# Actor
# R1, R2, R3, R4, R5, R6
# Opt
# TV
# EFF
# Total
reel_numbers = sorted(set([x.get('Reel', None) for x in records['events'] if 'Reel' in x.keys()]))
aux_columns = [{'heading': 'OPT', 'key': 'Optional'},
{'heading': 'TV', 'key': 'TV'},
{'heading': 'EFF', 'key': 'Effort'}]
sorted_character_numbers = sorted(set([x['CN'] for x in records['events']]),
key=lambda x: int(x))
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
page: GRect = GRect(0, 0, letter[1], letter[0])
page = page.inset(inch * 0.5)
headers = ['#', 'Role', 'Actor']
if len(reel_numbers) > 0:
for n in reel_numbers:
headers.append(n)
headers.append("Total")
for m in aux_columns:
headers.append(m['heading'])
line_count_data = [headers]
for cn in sorted_character_numbers:
this_row = [cn]
this_character_cues = [x for x in records['events'] if x['Character Number'] == cn]
this_row.append(this_character_cues[0].get('Character Name', ""))
this_row.append(this_character_cues[0].get('Actor Name', ""))
if len(reel_numbers) > 0:
for _ in reel_numbers:
this_row.append("X")
this_row.append(len([x for x in this_character_cues if 'Omit' not in x.keys()]))
for m in aux_columns:
this_row.append(0)
line_count_data.append(this_row)
pass
style = TableStyle([('FONTNAME', (0, 0), (-1, -1), 'Futura'),
('FONTSIZE', (0, 0), (-1, -1), 11),
('LINEBELOW', (0, 0), (-1, 0), 1.0, colors.black),
('ALIGN', (3, 1), (-1, -1), 'RIGHT')
]
)
table = Table(data=line_count_data, style=style, colWidths=[0.5 * inch, 1.25 * inch, 2. * inch, 0.5 * inch,
0.5 * inch, 0.5 * inch, 0.5 * inch, 0.5 * inch])
c = Canvas('Line Count.pdf', pagesize=(letter[1], letter[0]))
w, h = table.wrap(page.width, page.height)
table.drawOn(canvas=c, x=page.min_x, y=page.max_y - h)
c.showPage()
c.save()

View File

@@ -0,0 +1,20 @@
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
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import Paragraph
from .common import GRect
import datetime
def output_report(records):
# order by start
pass