mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Directive implementation
This commit is contained in:
@@ -61,10 +61,11 @@ class TagCompiler:
|
||||
|
||||
def compile_events(self) -> Iterator[Event]:
|
||||
step0 = self.parse_data()
|
||||
step1 = self.apply_appends(step0)
|
||||
step2 = self.collect_time_spans(step1)
|
||||
step3 = self.apply_tags(step2)
|
||||
for datum in step3:
|
||||
step1 = self.filter_out_directives(step0)
|
||||
step2 = self.apply_appends(step1)
|
||||
step3 = self.collect_time_spans(step2)
|
||||
step4 = self.apply_tags(step3)
|
||||
for datum in step4:
|
||||
yield Event(clip_name=datum[0], track_name=datum[1], session_name=datum[2],
|
||||
tags=datum[3], start=datum[4], finish=datum[5])
|
||||
|
||||
@@ -77,6 +78,14 @@ class TagCompiler:
|
||||
|
||||
return retval
|
||||
|
||||
def filter_out_directives(self, clips : Iterator[Intermediate]) -> Iterator[Intermediate]:
|
||||
for clip in clips:
|
||||
if clip.clip_tag_mode == 'Directive':
|
||||
continue
|
||||
else:
|
||||
yield clip
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _coalesce_tags(clip_tags: dict, track_tags: dict,
|
||||
track_comment_tags: dict,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from parsimonious import NodeVisitor, Grammar
|
||||
from typing import Dict, Optional
|
||||
from typing import Dict, Union
|
||||
from enum import Enum
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ class TagPreModes(Enum):
|
||||
NORMAL = 'Normal'
|
||||
APPEND = 'Append'
|
||||
TIMESPAN = 'Timespan'
|
||||
DIRECTIVE = 'Directive'
|
||||
|
||||
|
||||
tag_grammar = Grammar(
|
||||
@@ -23,7 +24,7 @@ tag_grammar = Grammar(
|
||||
tag_junk = word word_sep?
|
||||
word = ~r"[^ \[\{\$][^ ]*"
|
||||
word_sep = ~r" +"
|
||||
modifier = ("@" / "&" / "!") word_sep?
|
||||
modifier = ("@" / "&" /"!") word_sep?
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -51,7 +52,7 @@ class TagListVisitor(NodeVisitor):
|
||||
modifier_opt, line_opt, _, tag_list_opt = visited_children
|
||||
|
||||
return TaggedStringResult(content=next(iter(line_opt), None),
|
||||
tag_dict=next(iter(tag_list_opt), dict()),
|
||||
tag_dict=next(iter(tag_list_opt), dict()),
|
||||
mode=TagPreModes(next(iter(modifier_opt), 'Normal'))
|
||||
)
|
||||
|
||||
@@ -65,6 +66,8 @@ class TagListVisitor(NodeVisitor):
|
||||
return TagPreModes.TIMESPAN
|
||||
elif node.text.startswith('&'):
|
||||
return TagPreModes.APPEND
|
||||
elif node.text.startswith('!'):
|
||||
return TagPreModes.DIRECTIVE
|
||||
else:
|
||||
return TagPreModes.NORMAL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user