mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Style work
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from parsimonious.nodes import NodeVisitor
|
||||
from parsimonious.nodes import NodeVisitor, Node
|
||||
|
||||
|
||||
class DictionaryParserVisitor(NodeVisitor):
|
||||
def visit_document(self, node, visited_children):
|
||||
|
||||
@staticmethod
|
||||
def visit_document(node: Node, visited_children) -> dict:
|
||||
files = next(iter(visited_children[1]), None)
|
||||
clips = next(iter(visited_children[2]), None)
|
||||
plugins = next(iter(visited_children[3]), None)
|
||||
@@ -16,7 +18,8 @@ class DictionaryParserVisitor(NodeVisitor):
|
||||
tracks=tracks,
|
||||
markers=markers)
|
||||
|
||||
def visit_header(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_header(node, visited_children):
|
||||
|
||||
tc_drop = False
|
||||
for _ in visited_children[20]:
|
||||
@@ -32,14 +35,17 @@ class DictionaryParserVisitor(NodeVisitor):
|
||||
count_clips=visited_children[29],
|
||||
count_files=visited_children[33])
|
||||
|
||||
def visit_files_section(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_files_section(node, visited_children):
|
||||
return list(map(lambda child: dict(filename=child[0], path=child[2]), visited_children[2]))
|
||||
|
||||
def visit_clips_section(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_clips_section(node, visited_children):
|
||||
return list(map(lambda child: dict(clip_name=child[0], file=child[2], channel=child[5]),
|
||||
visited_children[2]))
|
||||
|
||||
def visit_plugin_listing(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_plugin_listing(node, visited_children):
|
||||
return list(map(lambda child: dict(manufacturer=child[0],
|
||||
plugin_name=child[2],
|
||||
version=child[4],
|
||||
@@ -48,7 +54,8 @@ class DictionaryParserVisitor(NodeVisitor):
|
||||
count_instances=child[10]),
|
||||
visited_children[2]))
|
||||
|
||||
def visit_track_block(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_track_block(node, visited_children):
|
||||
track_header, track_clip_list = visited_children
|
||||
clips = []
|
||||
for clip in track_clip_list:
|
||||
@@ -69,10 +76,12 @@ class DictionaryParserVisitor(NodeVisitor):
|
||||
clips=clips
|
||||
)
|
||||
|
||||
def visit_track_listing(selfs, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_track_listing(node, visited_children):
|
||||
return visited_children[1]
|
||||
|
||||
def visit_track_clip_entry(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_track_clip_entry(node, visited_children):
|
||||
timestamp = None
|
||||
if isinstance(visited_children[14], list):
|
||||
timestamp = visited_children[14][0][0]
|
||||
@@ -86,16 +95,19 @@ class DictionaryParserVisitor(NodeVisitor):
|
||||
timestamp=timestamp,
|
||||
state=visited_children[15])
|
||||
|
||||
def visit_track_state_list(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_track_state_list(node, visited_children):
|
||||
states = []
|
||||
for next_state in visited_children:
|
||||
states.append(next_state[0][0].text)
|
||||
return states
|
||||
|
||||
def visit_track_clip_state(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_track_clip_state(node, visited_children):
|
||||
return node.text
|
||||
|
||||
def visit_markers_listing(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_markers_listing(node, visited_children):
|
||||
markers = []
|
||||
|
||||
for marker in visited_children[2]:
|
||||
@@ -103,7 +115,8 @@ class DictionaryParserVisitor(NodeVisitor):
|
||||
|
||||
return markers
|
||||
|
||||
def visit_marker_record(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_marker_record(node, visited_children):
|
||||
return dict(number=visited_children[0],
|
||||
location=visited_children[3],
|
||||
time_reference=visited_children[5],
|
||||
@@ -111,20 +124,23 @@ class DictionaryParserVisitor(NodeVisitor):
|
||||
name=visited_children[10],
|
||||
comments=visited_children[12])
|
||||
|
||||
|
||||
def visit_formatted_clip_name(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_formatted_clip_name(_, visited_children):
|
||||
return visited_children[1].text
|
||||
|
||||
def visit_string_value(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_string_value(node, visited_children):
|
||||
return node.text.strip(" ")
|
||||
|
||||
def visit_integer_value(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_integer_value(node, visited_children):
|
||||
return int(node.text)
|
||||
|
||||
# def visit_timecode_value(self, node, visited_children):
|
||||
# return node.text.strip(" ")
|
||||
|
||||
def visit_float_value(self, node, visited_children):
|
||||
@staticmethod
|
||||
def visit_float_value(node, visited_children):
|
||||
return float(node.text)
|
||||
|
||||
def visit_block_ending(self, node, visited_children):
|
||||
|
||||
Reference in New Issue
Block a user