mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Some functional util code
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from ptulsconv.broadcast_timecode import smpte_to_frame_count
|
from ptulsconv.broadcast_timecode import smpte_to_frame_count
|
||||||
from typing import Tuple, List
|
from typing import Tuple, List, Generator
|
||||||
|
from . import apply_appends
|
||||||
|
from .tagged_string_parser_visitor import parse_tags
|
||||||
|
|
||||||
|
|
||||||
class SessionDescriptor:
|
class SessionDescriptor:
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
from parsimonious import NodeVisitor, Grammar
|
from parsimonious import NodeVisitor, Grammar
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class TagPreModes(Enum):
|
||||||
|
NORMAL = 'Normal'
|
||||||
|
APPEND = 'Append'
|
||||||
|
TIMESPAN = 'Timespan'
|
||||||
|
|
||||||
|
|
||||||
tag_grammar = Grammar(
|
tag_grammar = Grammar(
|
||||||
@@ -16,7 +23,7 @@ tag_grammar = Grammar(
|
|||||||
tag_junk = word word_sep?
|
tag_junk = word word_sep?
|
||||||
word = ~"[^ \[\{\$][^ ]*"
|
word = ~"[^ \[\{\$][^ ]*"
|
||||||
word_sep = ~" +"
|
word_sep = ~" +"
|
||||||
modifier = ("@" / "&" / "!") word_sep?
|
modifier = ("@" / "&") word_sep?
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -55,13 +62,11 @@ class TagListVisitor(NodeVisitor):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def visit_modifier(node, _):
|
def visit_modifier(node, _):
|
||||||
if node.text.startswith('@'):
|
if node.text.startswith('@'):
|
||||||
return 'Timespan'
|
return TagPreModes.TIMESPAN
|
||||||
elif node.text.startswith('&'):
|
elif node.text.startswith('&'):
|
||||||
return 'Append'
|
return TagPreModes.APPEND
|
||||||
elif node.text.startswith('!'):
|
|
||||||
return 'Movie'
|
|
||||||
else:
|
else:
|
||||||
return 'Normal'
|
return TagPreModes.NORMAL
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def visit_tag_list(_, visited_children):
|
def visit_tag_list(_, visited_children):
|
||||||
|
|||||||
Reference in New Issue
Block a user