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,37 +1,60 @@
|
|||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
|
||||||
|
|
||||||
from ptulsconv import __name__, __version__, __author__
|
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
|
from ptulsconv.reporting import print_status_style, print_banner_style, print_section_header_style, print_fatal_error
|
||||||
|
|
||||||
#TODO: Support Top-level modes
|
|
||||||
|
# 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():
|
def main():
|
||||||
|
"""Entry point for the command-line invocation"""
|
||||||
parser = OptionParser()
|
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',
|
parser.add_option('-f', '--format',
|
||||||
choices=['raw', 'json', 'adr'], default='adr',
|
dest='output_format',
|
||||||
help='Set output format, `raw`, `json`, `adr`. Default '
|
metavar='FMT',
|
||||||
'is `adr`.')
|
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 = OptionGroup(title="Warning and Validation Options",
|
||||||
warn_options.add_option('-W', action='store_false', dest='warnings', default=True,
|
parser=parser)
|
||||||
|
|
||||||
|
warn_options.add_option('-W', action='store_false',
|
||||||
|
dest='warnings',
|
||||||
|
default=True,
|
||||||
help='Suppress warnings for common errors (missing code numbers etc.)')
|
help='Suppress warnings for common errors (missing code numbers etc.)')
|
||||||
|
|
||||||
parser.add_option_group(warn_options)
|
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 '
|
description='Print useful information and exit without processing '
|
||||||
'input files.')
|
'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',
|
action='store_true',
|
||||||
default=False, help='Display tag mappings for the FMP XML '
|
default=False,
|
||||||
'output style and exit.')
|
help='Display tag mappings for the FMP XML '
|
||||||
|
'output style and exit.')
|
||||||
|
|
||||||
parser.add_option_group(informational_options)
|
parser.add_option_group(informational_options)
|
||||||
|
|
||||||
@@ -54,10 +77,13 @@ def main():
|
|||||||
try:
|
try:
|
||||||
output_format = options.output_format
|
output_format = options.output_format
|
||||||
convert(input_file=args[1], output_format=output_format, warnings=options.warnings)
|
convert(input_file=args[1], output_format=output_format, warnings=options.warnings)
|
||||||
|
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
print_fatal_error("Error trying to read input file")
|
print_fatal_error("Error trying to read input file")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
print_fatal_error("Error trying to convert file")
|
print_fatal_error("Error trying to convert file")
|
||||||
print("\033[31m" + e.__repr__() + "\033[0m", file=sys.stderr)
|
print("\033[31m" + e.__repr__() + "\033[0m", file=sys.stderr)
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
import csv
|
import csv
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import ptulsconv
|
import ptulsconv
|
||||||
from .reporting import print_section_header_style, print_status_style, print_warning
|
from .reporting import print_section_header_style, print_status_style, print_warning
|
||||||
@@ -33,13 +33,6 @@ class MyEncoder(JSONEncoder):
|
|||||||
return o.__dict__
|
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):
|
def output_adr_csv(lines: List[ADRLine], time_format: TimecodeFormat):
|
||||||
reels = set([ln.reel for ln in lines])
|
reels = set([ln.reel for ln in lines])
|
||||||
|
|
||||||
@@ -79,7 +72,7 @@ def output_avid_markers(lines):
|
|||||||
pass
|
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")
|
print_section_header_style("Creating PDF Reports")
|
||||||
report_date = datetime.datetime.now()
|
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)
|
output_summary(lines, tc_display_format=tc_display_format)
|
||||||
|
|
||||||
print_status_style("Creating Line Count")
|
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")
|
print_status_style("Creating Supervisor Logs directory and reports")
|
||||||
os.makedirs("Supervisor Logs", exist_ok=True)
|
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 = TagCompiler()
|
||||||
compiler.session = session
|
compiler.session = session
|
||||||
compiled_events = list(compiler.compile_events())
|
compiled_events = list(compiler.compile_events())
|
||||||
if output_format == 'json':
|
if output_format == 'tagged':
|
||||||
output.write(MyEncoder().encode(compiled_events))
|
output.write(MyEncoder().encode(compiled_events))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -163,8 +156,13 @@ def convert(input_file, output_format='fmpxml', output=sys.stdout, warnings=True
|
|||||||
dependent_field='actor_name')):
|
dependent_field='actor_name')):
|
||||||
print_warning(warning.report_message())
|
print_warning(warning.report_message())
|
||||||
|
|
||||||
if output_format == 'adr':
|
if output_format == 'doc':
|
||||||
create_adr_reports(lines, tc_display_format=session_tc_format)
|
|
||||||
|
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':
|
# elif output_format == 'csv':
|
||||||
# dump_csv(parsed['events'])
|
# dump_csv(parsed['events'])
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class TagCompiler:
|
|||||||
|
|
||||||
session: doc_entity.SessionDescriptor
|
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()
|
ret_list = list()
|
||||||
for element in self.parse_data():
|
for element in self.parse_data():
|
||||||
if element.clip_tag_mode == TagPreModes.TIMESPAN:
|
if element.clip_tag_mode == TagPreModes.TIMESPAN:
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ from reportlab.pdfbase.ttfonts import TTFont
|
|||||||
|
|
||||||
from ptulsconv.docparser.adr_entity import ADRLine
|
from ptulsconv.docparser.adr_entity import ADRLine
|
||||||
|
|
||||||
#TODO: A Generic report useful for spotting
|
|
||||||
#TODO: A report useful for M&E mixer's notes
|
# TODO: A Generic report useful for spotting
|
||||||
#TODO: Address all style notes this file
|
# TODO: A Continuity
|
||||||
|
# TODO: A report useful for M&E mixer's notes
|
||||||
|
# TODO: Address all style notes this file
|
||||||
|
|
||||||
# This is from https://code.activestate.com/recipes/576832/ for
|
# This is from https://code.activestate.com/recipes/576832/ for
|
||||||
# generating page count messages
|
# generating page count messages
|
||||||
@@ -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=""):
|
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., ])
|
(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.)
|
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.)
|
client.draw_text_cell(a_canvas, record.client, "Futura", 11, inset_y=2., inset_x=5.)
|
||||||
|
|||||||
Reference in New Issue
Block a user