From f514dde259e7e73503bb9eb7d66cccc7e53fdb0c Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Thu, 27 May 2021 21:53:44 -0700 Subject: [PATCH] Refactoring adr parser --- ptulsconv/commands.py | 39 +----------------------- ptulsconv/docparser/adr_entity.py | 49 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/ptulsconv/commands.py b/ptulsconv/commands.py index cc8523a..a81bf76 100644 --- a/ptulsconv/commands.py +++ b/ptulsconv/commands.py @@ -15,44 +15,7 @@ from ptulsconv.pdf.line_count import output_report as output_line_count from ptulsconv.pdf.talent_sides import output_report as output_talent_sides from ptulsconv.pdf.summary_log import output_report as output_summary -# 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 1 is the field in FMPXMLRESULT -# - tuple field 2 the constructor/type of the field -adr_field_map = ((['Title', 'PT.Session.Name'], 'Title', str), - (['Supv'], 'Supervisor', str), - (['Client'], 'Client', str), - (['Sc'], 'Scene', str), - (['Ver'], 'Version', str), - (['Reel'], 'Reel', str), - (['PT.Clip.Start'], 'Start', str), - (['PT.Clip.Finish'], 'Finish', str), - (['PT.Clip.Start_Seconds'], 'Start Seconds', float), - (['PT.Clip.Finish_Seconds'], 'Finish Seconds', float), - (['PT.Clip.Start_Frames'], 'Start Frames', int), - (['PT.Clip.Finish_Frames'], 'Finish Frames', int), - (['P'], 'Priority', int), - (['QN'], 'Cue Number', str), - (['Char', 'PT.Track.Name'], 'Character Name', str), - (['Actor'], 'Actor Name', str), - (['CN'], 'Character Number', str), - (['R'], 'Reason', str), - (['Rq'], 'Requested by', str), - (['Spot'], 'Spot', str), - (['PT.Clip.Name', 'Line'], 'Line', str), - (['Shot'], 'Shot', str), - (['Note'], 'Note', str), - (['Mins'], 'Time Budget Mins', float), - (['EFF'], 'Effort', str), - (['TV'], 'TV', str), - (['TBW'], 'To Be Written', str), - (['OMIT'], 'Omit', str), - (['ADLIB'], 'Adlib', str), - (['OPT'], 'Optional', str), - (['DONE'], 'Done', str), - (['Movie.Filename'], 'Movie', str), - (['Movie.Start_Offset_Seconds'], 'Movie Seconds', float), - ) +from .docparser.adr_entity import adr_field_map def dump_csv(events, output=sys.stdout): diff --git a/ptulsconv/docparser/adr_entity.py b/ptulsconv/docparser/adr_entity.py index 70b59ae..56d231a 100644 --- a/ptulsconv/docparser/adr_entity.py +++ b/ptulsconv/docparser/adr_entity.py @@ -1,5 +1,54 @@ from .doc_entity import SessionDescriptor +from .tagged_string_parser_visitor import parse_tags + +# 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 1 is the field in FMPXMLRESULT +# - tuple field 2 the constructor/type of the field + +adr_field_map = ((['Title', 'PT.Session.Name'], 'Title', str), + (['Supv'], 'Supervisor', str), + (['Client'], 'Client', str), + (['Sc'], 'Scene', str), + (['Ver'], 'Version', str), + (['Reel'], 'Reel', str), + (['PT.Clip.Start'], 'Start', str), + (['PT.Clip.Finish'], 'Finish', str), + (['PT.Clip.Start_Seconds'], 'Start Seconds', float), + (['PT.Clip.Finish_Seconds'], 'Finish Seconds', float), + (['PT.Clip.Start_Frames'], 'Start Frames', int), + (['PT.Clip.Finish_Frames'], 'Finish Frames', int), + (['P'], 'Priority', int), + (['QN'], 'Cue Number', str), + (['Char', 'PT.Track.Name'], 'Character Name', str), + (['Actor'], 'Actor Name', str), + (['CN'], 'Character Number', str), + (['R'], 'Reason', str), + (['Rq'], 'Requested by', str), + (['Spot'], 'Spot', str), + (['PT.Clip.Name', 'Line'], 'Line', str), + (['Shot'], 'Shot', str), + (['Note'], 'Note', str), + (['Mins'], 'Time Budget Mins', float), + (['EFF'], 'Effort', str), + (['TV'], 'TV', str), + (['TBW'], 'To Be Written', str), + (['OMIT'], 'Omit', str), + (['ADLIB'], 'Adlib', str), + (['OPT'], 'Optional', str), + (['DONE'], 'Done', str), + (['Movie.Filename'], 'Movie', str), + (['Movie.Start_Offset_Seconds'], 'Movie Seconds', float), + ) + class ADRDocument: + document: SessionDescriptor + def __init__(self, session: SessionDescriptor): self.document = session + + def lines(self): + header_metadata = parse_tags(self.document.header.session_name) + #TODO continue +