mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 17:00:46 +00:00
Bugfixes/linted
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import sys
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from typing import Iterator, Tuple, Callable, Generator, Dict, List
|
from typing import Iterator, Tuple, Callable, Generator, Dict, List
|
||||||
@@ -72,9 +71,9 @@ class TagCompiler:
|
|||||||
def _marker_tags(self, at):
|
def _marker_tags(self, at):
|
||||||
retval = dict()
|
retval = dict()
|
||||||
applicable = [(m, t) for (m, t) in self.session.markers_timed() if t <= at]
|
applicable = [(m, t) for (m, t) in self.session.markers_timed() if t <= at]
|
||||||
for marker, time in sorted(applicable, key=lambda x: x[1]):
|
for marker, _ in sorted(applicable, key=lambda x: x[1]):
|
||||||
retval.update(parse_tags(marker.comments).tag_dict)
|
retval.update(parse_tags(marker.comments or "").tag_dict)
|
||||||
retval.update(parse_tags(marker.name).tag_dict)
|
retval.update(parse_tags(marker.name or "").tag_dict)
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
@@ -186,4 +185,4 @@ def apply_appends(source: Iterator,
|
|||||||
yield this_element
|
yield this_element
|
||||||
this_element = element
|
this_element = element
|
||||||
|
|
||||||
yield this_element
|
yield this_element
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ tag_grammar = Grammar(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_tags(prompt) -> "TaggedStringResult":
|
def parse_tags(prompt: str) -> "TaggedStringResult":
|
||||||
ast = tag_grammar.parse(prompt)
|
ast = tag_grammar.parse(prompt)
|
||||||
return TagListVisitor().visit(ast)
|
return TagListVisitor().visit(ast)
|
||||||
|
|
||||||
|
|
||||||
class TaggedStringResult:
|
class TaggedStringResult:
|
||||||
content: Optional[str]
|
content: str
|
||||||
tag_dict: Optional[Dict[str, str]]
|
tag_dict: Dict[str, str]
|
||||||
mode: TagPreModes
|
mode: TagPreModes
|
||||||
|
|
||||||
def __init__(self, content, tag_dict, mode):
|
def __init__(self, content, tag_dict, mode):
|
||||||
|
|||||||
Reference in New Issue
Block a user