mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Addressed Line count feature
This commit is contained in:
@@ -1,36 +1,59 @@
|
||||
from optparse import OptionParser, OptionGroup
|
||||
import datetime
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from ptulsconv import __name__, __version__, __author__
|
||||
from ptulsconv.commands import convert, dump_field_map
|
||||
from ptulsconv.commands import convert
|
||||
from ptulsconv.reporting import print_status_style, print_banner_style, print_section_header_style, print_fatal_error
|
||||
|
||||
|
||||
# TODO: Support Top-level modes
|
||||
|
||||
# Modes we want:
|
||||
# - "raw" : Output the parsed text export document with no further processing, as json
|
||||
# - "tagged"? : Output the parsed result of the TagCompiler
|
||||
# - "doc" : Generate a full panoply of PDF reports contextually based on tagging
|
||||
|
||||
|
||||
def dump_field_map(output=sys.stdout):
|
||||
from ptulsconv.docparser.tag_mapping import TagMapping
|
||||
from ptulsconv.docparser.adr_entity import ADRLine
|
||||
|
||||
TagMapping.print_rules(ADRLine, output=output)
|
||||
|
||||
|
||||
def main():
|
||||
"""Entry point for the command-line invocation"""
|
||||
parser = OptionParser()
|
||||
parser.usage = "ptulsconv TEXT_EXPORT.txt"
|
||||
parser.usage = "ptulsconv [options] TEXT_EXPORT.txt"
|
||||
|
||||
parser.add_option('-f', '--format', dest='output_format', metavar='FMT',
|
||||
choices=['raw', 'json', 'adr'], default='adr',
|
||||
help='Set output format, `raw`, `json`, `adr`. Default '
|
||||
'is `adr`.')
|
||||
parser.add_option('-f', '--format',
|
||||
dest='output_format',
|
||||
metavar='FMT',
|
||||
choices=['raw', 'tagged', 'doc'],
|
||||
default='doc',
|
||||
help='Set output format, `raw`, `tagged`, `doc`.')
|
||||
|
||||
warn_options = OptionGroup(title="Warning and Validation Options", parser=parser)
|
||||
warn_options.add_option('-W', action='store_false', dest='warnings', default=True,
|
||||
warn_options = OptionGroup(title="Warning and Validation Options",
|
||||
parser=parser)
|
||||
|
||||
warn_options.add_option('-W', action='store_false',
|
||||
dest='warnings',
|
||||
default=True,
|
||||
help='Suppress warnings for common errors (missing code numbers etc.)')
|
||||
|
||||
parser.add_option_group(warn_options)
|
||||
|
||||
informational_options = OptionGroup(title="Informational Options", parser=parser,
|
||||
informational_options = OptionGroup(title="Informational Options",
|
||||
parser=parser,
|
||||
description='Print useful information and exit without processing '
|
||||
'input files.')
|
||||
|
||||
informational_options.add_option('--show-available-tags', dest='show_tags',
|
||||
informational_options.add_option('--show-available-tags',
|
||||
dest='show_tags',
|
||||
action='store_true',
|
||||
default=False, help='Display tag mappings for the FMP XML '
|
||||
default=False,
|
||||
help='Display tag mappings for the FMP XML '
|
||||
'output style and exit.')
|
||||
|
||||
parser.add_option_group(informational_options)
|
||||
@@ -54,10 +77,13 @@ def main():
|
||||
try:
|
||||
output_format = options.output_format
|
||||
convert(input_file=args[1], output_format=output_format, warnings=options.warnings)
|
||||
|
||||
except FileNotFoundError as e:
|
||||
print_fatal_error("Error trying to read input file")
|
||||
raise e
|
||||
|
||||
except Exception as e:
|
||||
import traceback
|
||||
print_fatal_error("Error trying to convert file")
|
||||
print("\033[31m" + e.__repr__() + "\033[0m", file=sys.stderr)
|
||||
print(traceback.format_exc())
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
|
||||
import sys
|
||||
from itertools import chain
|
||||
import csv
|
||||
from typing import List
|
||||
|
||||
import ptulsconv
|
||||
from .reporting import print_section_header_style, print_status_style, print_warning
|
||||
@@ -33,13 +33,6 @@ class MyEncoder(JSONEncoder):
|
||||
return o.__dict__
|
||||
|
||||
|
||||
def dump_field_map(output=sys.stdout):
|
||||
from ptulsconv.docparser.tag_mapping import TagMapping
|
||||
from ptulsconv.docparser.adr_entity import ADRLine
|
||||
|
||||
TagMapping.print_rules(ADRLine, output=output)
|
||||
|
||||
|
||||
def output_adr_csv(lines: List[ADRLine], time_format: TimecodeFormat):
|
||||
reels = set([ln.reel for ln in lines])
|
||||
|
||||
@@ -79,7 +72,7 @@ def output_avid_markers(lines):
|
||||
pass
|
||||
|
||||
|
||||
def create_adr_reports(lines: List[ADRLine], tc_display_format: TimecodeFormat):
|
||||
def create_adr_reports(lines: List[ADRLine], tc_display_format: TimecodeFormat, reel_list):
|
||||
|
||||
print_section_header_style("Creating PDF Reports")
|
||||
report_date = datetime.datetime.now()
|
||||
@@ -91,7 +84,7 @@ def create_adr_reports(lines: List[ADRLine], tc_display_format: TimecodeFormat):
|
||||
output_summary(lines, tc_display_format=tc_display_format)
|
||||
|
||||
print_status_style("Creating Line Count")
|
||||
output_line_count(lines, reel_list=['R1', 'R2', 'R3', 'R4', 'R5', 'R6'])
|
||||
output_line_count(lines, reel_list=reel_list)
|
||||
|
||||
print_status_style("Creating Supervisor Logs directory and reports")
|
||||
os.makedirs("Supervisor Logs", exist_ok=True)
|
||||
@@ -146,7 +139,7 @@ def convert(input_file, output_format='fmpxml', output=sys.stdout, warnings=True
|
||||
compiler = TagCompiler()
|
||||
compiler.session = session
|
||||
compiled_events = list(compiler.compile_events())
|
||||
if output_format == 'json':
|
||||
if output_format == 'tagged':
|
||||
output.write(MyEncoder().encode(compiled_events))
|
||||
|
||||
else:
|
||||
@@ -163,8 +156,13 @@ def convert(input_file, output_format='fmpxml', output=sys.stdout, warnings=True
|
||||
dependent_field='actor_name')):
|
||||
print_warning(warning.report_message())
|
||||
|
||||
if output_format == 'adr':
|
||||
create_adr_reports(lines, tc_display_format=session_tc_format)
|
||||
if output_format == 'doc':
|
||||
|
||||
reels = sorted([r for r in compiler.compile_all_time_spans() if r[0] == 'Reel'],
|
||||
key=lambda x: x[2])
|
||||
|
||||
create_adr_reports(lines, tc_display_format=session_tc_format,
|
||||
reel_list=sorted(reels))
|
||||
|
||||
# elif output_format == 'csv':
|
||||
# dump_csv(parsed['events'])
|
||||
|
||||
@@ -26,7 +26,7 @@ class TagCompiler:
|
||||
|
||||
session: doc_entity.SessionDescriptor
|
||||
|
||||
def compile_all_timespans(self) -> List[Tuple[str, str, Fraction, Fraction]]:
|
||||
def compile_all_time_spans(self) -> List[Tuple[str, str, Fraction, Fraction]]:
|
||||
ret_list = list()
|
||||
for element in self.parse_data():
|
||||
if element.clip_tag_mode == TagPreModes.TIMESPAN:
|
||||
|
||||
@@ -10,7 +10,9 @@ from reportlab.pdfbase.ttfonts import TTFont
|
||||
|
||||
from ptulsconv.docparser.adr_entity import ADRLine
|
||||
|
||||
|
||||
# TODO: A Generic report useful for spotting
|
||||
# TODO: A Continuity
|
||||
# TODO: A report useful for M&E mixer's notes
|
||||
# TODO: Address all style notes this file
|
||||
|
||||
@@ -98,7 +100,6 @@ def time_format(mins, zero_str=""):
|
||||
|
||||
|
||||
def draw_header_footer(a_canvas: ReportCanvas, title_box, doc_title_box, footer_box, record: ADRLine, doc_title=""):
|
||||
|
||||
(supervisor, client,), title = title_box.divide_y([16., 16., ])
|
||||
title.draw_text_cell(a_canvas, record.title, "Futura", 18, inset_y=2., inset_x=5.)
|
||||
client.draw_text_cell(a_canvas, record.client, "Futura", 11, inset_y=2., inset_x=5.)
|
||||
|
||||
Reference in New Issue
Block a user