mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 17:00:46 +00:00
flake8
This commit is contained in:
@@ -1 +1 @@
|
|||||||
from dataclasses import dataclass
|
# from dataclasses import dataclass
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ class TagMapping:
|
|||||||
for rule in rules:
|
for rule in rules:
|
||||||
if rule.target in done:
|
if rule.target in done:
|
||||||
continue
|
continue
|
||||||
if rule.apply(tags, clip_content, track_content, session_content, to):
|
if rule.apply(tags, clip_content, track_content, session_content,
|
||||||
|
to):
|
||||||
done.update(rule.target)
|
done.update(rule.target)
|
||||||
|
|
||||||
def __init__(self, source: str,
|
def __init__(self, source: str,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from parsimonious import NodeVisitor, Grammar
|
from parsimonious import NodeVisitor, Grammar
|
||||||
from typing import Dict, Union
|
from typing import Dict
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
@@ -52,8 +52,9 @@ class TagListVisitor(NodeVisitor):
|
|||||||
modifier_opt, line_opt, _, tag_list_opt = visited_children
|
modifier_opt, line_opt, _, tag_list_opt = visited_children
|
||||||
|
|
||||||
return TaggedStringResult(content=next(iter(line_opt), None),
|
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'))
|
mode=TagPreModes(
|
||||||
|
next(iter(modifier_opt), 'Normal'))
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
#import ffmpeg # ffmpeg-python
|
# import ffmpeg # ffmpeg-python
|
||||||
|
|
||||||
# TODO: Implement movie export
|
# TODO: Implement movie export
|
||||||
|
|
||||||
# def create_movie(event):
|
# def create_movie(event):
|
||||||
# start = event['Movie.Start_Offset_Seconds']
|
# start = event['Movie.Start_Offset_Seconds']
|
||||||
# duration = event['PT.Clip.Finish_Seconds'] - event['PT.Clip.Start_Seconds']
|
# duration = event['PT.Clip.Finish_Seconds'] -
|
||||||
|
# event['PT.Clip.Start_Seconds']
|
||||||
# input_movie = event['Movie.Filename']
|
# input_movie = event['Movie.Filename']
|
||||||
# print("Will make movie starting at {}, dur {} from movie {}".format(start, duration, input_movie))
|
# print("Will make movie starting at {}, dur {} from movie {}"
|
||||||
|
# .format(start, duration, input_movie))
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# def export_movies(events):
|
# def export_movies(events):
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ from typing import List
|
|||||||
|
|
||||||
# This is from https://code.activestate.com/recipes/576832/ for
|
# This is from https://code.activestate.com/recipes/576832/ for
|
||||||
# generating page count messages
|
# generating page count messages
|
||||||
|
|
||||||
|
|
||||||
class ReportCanvas(canvas.Canvas):
|
class ReportCanvas(canvas.Canvas):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
canvas.Canvas.__init__(self, *args, **kwargs)
|
canvas.Canvas.__init__(self, *args, **kwargs)
|
||||||
@@ -38,10 +40,12 @@ class ReportCanvas(canvas.Canvas):
|
|||||||
|
|
||||||
def draw_page_number(self, page_count):
|
def draw_page_number(self, page_count):
|
||||||
self.saveState()
|
self.saveState()
|
||||||
self.setFont('Helvetica', 10) #FIXME make this customizable
|
self.setFont('Helvetica', 10) # FIXME make this customizable
|
||||||
self.drawString(0.5 * inch, 0.5 * inch, "Page %d of %d" % (self._pageNumber, page_count))
|
self.drawString(0.5 * inch, 0.5 * inch,
|
||||||
|
"Page %d of %d" % (self._pageNumber, page_count))
|
||||||
right_edge = self._pagesize[0] - 0.5 * inch
|
right_edge = self._pagesize[0] - 0.5 * inch
|
||||||
self.drawRightString(right_edge, 0.5 * inch, self._report_date.strftime("%m/%d/%Y %H:%M"))
|
self.drawRightString(right_edge, 0.5 * inch,
|
||||||
|
self._report_date.strftime("%m/%d/%Y %H:%M"))
|
||||||
|
|
||||||
top_line = self.beginPath()
|
top_line = self.beginPath()
|
||||||
top_line.moveTo(0.5 * inch, 0.75 * inch)
|
top_line.moveTo(0.5 * inch, 0.75 * inch)
|
||||||
@@ -76,13 +80,15 @@ def make_doc_template(page_size, filename, document_title,
|
|||||||
title_box, report_box = header_box.split_x(3.5 * inch, direction='r')
|
title_box, report_box = header_box.split_x(3.5 * inch, direction='r')
|
||||||
|
|
||||||
on_page_lambda = (lambda c, _:
|
on_page_lambda = (lambda c, _:
|
||||||
draw_header_footer(c, report_box, title_box,
|
draw_header_footer(c, report_box, title_box,
|
||||||
footer_box,title=title,
|
footer_box, title=title,
|
||||||
supervisor=supervisor,
|
supervisor=supervisor,
|
||||||
document_subheader=document_subheader,
|
document_subheader=document_subheader,
|
||||||
client=client, doc_title=document_header))
|
client=client,
|
||||||
|
doc_title=document_header))
|
||||||
|
|
||||||
frames = [Frame(page_box.min_x, page_box.min_y, page_box.width, page_box.height)]
|
frames = [Frame(page_box.min_x, page_box.min_y,
|
||||||
|
page_box.width, page_box.height)]
|
||||||
|
|
||||||
page_template = PageTemplate(id="Main",
|
page_template = PageTemplate(id="Main",
|
||||||
frames=frames,
|
frames=frames,
|
||||||
@@ -119,12 +125,17 @@ def time_format(mins, zero_str="-"):
|
|||||||
return "%i:%02i" % (hh, mm)
|
return "%i:%02i" % (hh, mm)
|
||||||
|
|
||||||
|
|
||||||
def draw_header_footer(a_canvas: ReportCanvas, left_box, right_box, footer_box, title: str, supervisor: str,
|
def draw_header_footer(a_canvas: ReportCanvas, left_box, right_box,
|
||||||
document_subheader: str, client: str, doc_title="", font_name='Helvetica'):
|
footer_box, title: str, supervisor: str,
|
||||||
|
document_subheader: str, client: str, doc_title="",
|
||||||
|
font_name='Helvetica'):
|
||||||
|
|
||||||
(_supervisor_box, client_box,), title_box = right_box.divide_y([16., 16., ])
|
(_supervisor_box, client_box,), title_box = \
|
||||||
title_box.draw_text_cell(a_canvas, title, font_name, 18, inset_y=2., inset_x=5.)
|
right_box.divide_y([16., 16., ])
|
||||||
client_box.draw_text_cell(a_canvas, client, font_name, 11, inset_y=2., inset_x=5.)
|
title_box.draw_text_cell(a_canvas, title, font_name, 18,
|
||||||
|
inset_y=2., inset_x=5.)
|
||||||
|
client_box.draw_text_cell(a_canvas, client, font_name, 11,
|
||||||
|
inset_y=2., inset_x=5.)
|
||||||
|
|
||||||
a_canvas.saveState()
|
a_canvas.saveState()
|
||||||
a_canvas.setLineWidth(0.5)
|
a_canvas.setLineWidth(0.5)
|
||||||
@@ -139,16 +150,20 @@ def draw_header_footer(a_canvas: ReportCanvas, left_box, right_box, footer_box,
|
|||||||
a_canvas.drawPath(tline2)
|
a_canvas.drawPath(tline2)
|
||||||
a_canvas.restoreState()
|
a_canvas.restoreState()
|
||||||
|
|
||||||
(doc_title_cell, spotting_version_cell,), _ = left_box.divide_y([18., 14], direction='d')
|
(doc_title_cell, spotting_version_cell,), _ = \
|
||||||
|
left_box.divide_y([18., 14], direction='d')
|
||||||
|
|
||||||
doc_title_cell.draw_text_cell(a_canvas, doc_title, font_name, 14., inset_y=2.)
|
doc_title_cell.draw_text_cell(a_canvas, doc_title, font_name, 14.,
|
||||||
|
inset_y=2.)
|
||||||
|
|
||||||
if document_subheader is not None:
|
if document_subheader is not None:
|
||||||
spotting_version_cell.draw_text_cell(a_canvas, document_subheader, font_name, 12., inset_y=2.)
|
spotting_version_cell.draw_text_cell(a_canvas, document_subheader,
|
||||||
|
font_name, 12., inset_y=2.)
|
||||||
|
|
||||||
if supervisor is not None:
|
if supervisor is not None:
|
||||||
a_canvas.setFont(font_name, 11.)
|
a_canvas.setFont(font_name, 11.)
|
||||||
a_canvas.drawCentredString(footer_box.min_x + footer_box.width / 2., footer_box.min_y, supervisor)
|
a_canvas.drawCentredString(footer_box.min_x + footer_box.width / 2.,
|
||||||
|
footer_box.min_y, supervisor)
|
||||||
|
|
||||||
|
|
||||||
class GRect:
|
class GRect:
|
||||||
@@ -201,10 +216,12 @@ class GRect:
|
|||||||
else:
|
else:
|
||||||
if direction == 'l':
|
if direction == 'l':
|
||||||
return (GRect(self.min_x, self.min_y, at, self.height),
|
return (GRect(self.min_x, self.min_y, at, self.height),
|
||||||
GRect(self.min_x + at, self.y, self.width - at, self.height))
|
GRect(self.min_x + at, self.y,
|
||||||
|
self.width - at, self.height))
|
||||||
else:
|
else:
|
||||||
return (GRect(self.max_x - at, self.y, at, self.height),
|
return (GRect(self.max_x - at, self.y, at, self.height),
|
||||||
GRect(self.min_x, self.y, self.width - at, self.height))
|
GRect(self.min_x, self.y,
|
||||||
|
self.width - at, self.height))
|
||||||
|
|
||||||
def split_y(self, at, direction='u'):
|
def split_y(self, at, direction='u'):
|
||||||
if at >= self.height:
|
if at >= self.height:
|
||||||
@@ -214,19 +231,23 @@ class GRect:
|
|||||||
else:
|
else:
|
||||||
if direction == 'u':
|
if direction == 'u':
|
||||||
return (GRect(self.x, self.y, self.width, at),
|
return (GRect(self.x, self.y, self.width, at),
|
||||||
GRect(self.x, self.y + at, self.width, self.height - at))
|
GRect(self.x, self.y + at,
|
||||||
|
self.width, self.height - at))
|
||||||
else:
|
else:
|
||||||
return (GRect(self.x, self.max_y - at, self.width, at),
|
return (GRect(self.x, self.max_y - at, self.width, at),
|
||||||
GRect(self.x, self.y, self.width, self.height - at))
|
GRect(self.x, self.y,
|
||||||
|
self.width, self.height - at))
|
||||||
|
|
||||||
def inset_xy(self, dx, dy):
|
def inset_xy(self, dx, dy):
|
||||||
return GRect(self.x + dx, self.y + dy, self.width - dx * 2, self.height - dy * 2)
|
return GRect(self.x + dx, self.y + dy,
|
||||||
|
self.width - dx * 2, self.height - dy * 2)
|
||||||
|
|
||||||
def inset(self, d):
|
def inset(self, d):
|
||||||
return self.inset_xy(d, d)
|
return self.inset_xy(d, d)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<GRect x=%f y=%f width=%f height=%f>" % (self.x, self.y, self.width, self.height)
|
return "<GRect x=%f y=%f width=%f height=%f>" % \
|
||||||
|
(self.x, self.y, self.width, self.height)
|
||||||
|
|
||||||
def divide_x(self, x_list, direction='l'):
|
def divide_x(self, x_list, direction='l'):
|
||||||
ret_list = list()
|
ret_list = list()
|
||||||
@@ -259,13 +280,17 @@ class GRect:
|
|||||||
|
|
||||||
def draw_border_impl(en):
|
def draw_border_impl(en):
|
||||||
if en == 'min_x':
|
if en == 'min_x':
|
||||||
coordinates = ((self.min_x, self.min_y), (self.min_x, self.max_y))
|
coordinates = ((self.min_x, self.min_y),
|
||||||
|
(self.min_x, self.max_y))
|
||||||
elif en == 'max_x':
|
elif en == 'max_x':
|
||||||
coordinates = ((self.max_x, self.min_y), (self.max_x, self.max_y))
|
coordinates = ((self.max_x, self.min_y),
|
||||||
|
(self.max_x, self.max_y))
|
||||||
elif en == 'min_y':
|
elif en == 'min_y':
|
||||||
coordinates = ((self.min_x, self.min_y), (self.max_x, self.min_y))
|
coordinates = ((self.min_x, self.min_y),
|
||||||
|
(self.max_x, self.min_y))
|
||||||
elif en == 'max_y':
|
elif en == 'max_y':
|
||||||
coordinates = ((self.min_x, self.max_y), (self.max_x, self.max_y))
|
coordinates = ((self.min_x, self.max_y),
|
||||||
|
(self.max_x, self.max_y))
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user