mirror of
https://github.com/iluvcapra/pycmx.git
synced 2025-12-31 08:50:54 +00:00
Flake8 lints, flake8 linting fully activated.
This commit is contained in:
@@ -12,6 +12,7 @@ logging.basicConfig(format=FORMAT)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def all_video_edits(edl):
|
||||
for event in edl.events:
|
||||
for edit in event.edits:
|
||||
@@ -30,46 +31,49 @@ def get_scene_name(edit, pattern):
|
||||
else:
|
||||
return edit.clip_name
|
||||
|
||||
|
||||
def output_cmx(outfile, out_list):
|
||||
outfile.write("TITLE: SCENE LIST\r\n")
|
||||
outfile.write("FCM: NON-DROP FRAME\r\n")
|
||||
|
||||
for o in out_list:
|
||||
line = "%03i AX V C 00:00:00:00 00:00:00:00 %s %s\r\n" % (0, o['start'],o['end'])
|
||||
line = "%03i AX V C 00:00:00:00 00:00:00:00 %s %s\r\n" % (
|
||||
0, o['start'], o['end'])
|
||||
outfile.write(line)
|
||||
outfile.write("* FROM CLIP NAME: %s\r\n" % (o['scene']) )
|
||||
outfile.write("* FROM CLIP NAME: %s\r\n" % (o['scene']))
|
||||
|
||||
|
||||
def output_cols(outfile, out_list):
|
||||
for o in out_list:
|
||||
outfile.write("%-12s\t%-12s\t%s\n" % (o['start'], o['end'], o['scene'] ))
|
||||
outfile.write("%-12s\t%-12s\t%s\n" %
|
||||
(o['start'], o['end'], o['scene']))
|
||||
|
||||
|
||||
def scene_list(infile, outfile, out_format, pattern):
|
||||
|
||||
|
||||
edl = pycmx.parse_cmx3600(infile)
|
||||
|
||||
current_scene_name = None
|
||||
|
||||
grouped_edits = [ ]
|
||||
|
||||
grouped_edits = []
|
||||
|
||||
for edit in all_video_edits(edl):
|
||||
this_scene_name = get_scene_name(edit, pattern)
|
||||
if this_scene_name is not None:
|
||||
if current_scene_name != this_scene_name:
|
||||
grouped_edits.append([ ])
|
||||
grouped_edits.append([])
|
||||
current_scene_name = this_scene_name
|
||||
|
||||
grouped_edits[-1].append(edit)
|
||||
|
||||
out_list = [ ]
|
||||
|
||||
out_list = []
|
||||
for group in grouped_edits:
|
||||
out_list.append({
|
||||
'start': group[0].record_in,
|
||||
out_list.append({
|
||||
'start': group[0].record_in,
|
||||
'end': group[-1].record_out,
|
||||
'scene': get_scene_name(group[0], pattern ) }
|
||||
)
|
||||
|
||||
'scene': get_scene_name(group[0], pattern)}
|
||||
)
|
||||
|
||||
if out_format == 'cmx':
|
||||
output_cmx(outfile, out_list)
|
||||
if out_format == 'cols':
|
||||
@@ -80,23 +84,24 @@ def scene_list(infile, outfile, out_format, pattern):
|
||||
|
||||
|
||||
def scene_list_cli():
|
||||
parser = argparse.ArgumentParser(description=
|
||||
'Read video events from an input CMX EDL and output events merged into scenes.')
|
||||
parser.add_argument('-o','--outfile', default=sys.stdout, type=argparse.FileType('w'),
|
||||
help='Output file. Default is stdout.')
|
||||
parser.add_argument('-f','--format', default='cmx', type=str,
|
||||
help='Output format. Options are cols and cmx, cmx is the default.')
|
||||
parser.add_argument('-p','--pattern', default='V?([A-Z]*[0-9]+)',
|
||||
help='RE pattern for extracting scene name from clip name. The default is "V?([A-Z]*[0-9]+)". ' + \
|
||||
'This pattern will be matched case-insensitively.')
|
||||
parser.add_argument('input_edl', default=sys.stdin, type=argparse.FileType('r'), nargs='?',
|
||||
help='Input file. Default is stdin.')
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Read video events from an input CMX EDL and output events merged into scenes.')
|
||||
parser.add_argument('-o', '--outfile', default=sys.stdout, type=argparse.FileType('w'),
|
||||
help='Output file. Default is stdout.')
|
||||
parser.add_argument('-f', '--format', default='cmx', type=str,
|
||||
help='Output format. Options are cols and cmx, cmx is the default.')
|
||||
parser.add_argument('-p', '--pattern', default='V?([A-Z]*[0-9]+)',
|
||||
help='RE pattern for extracting scene name from clip name. The default is "V?([A-Z]*[0-9]+)". ' +
|
||||
'This pattern will be matched case-insensitively.')
|
||||
parser.add_argument('input_edl', default=sys.stdin, type=argparse.FileType('r'), nargs='?',
|
||||
help='Input file. Default is stdin.')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
infile = args.input_edl
|
||||
|
||||
scene_list(infile=infile, outfile=args.outfile , out_format=args.format, pattern=args.pattern)
|
||||
scene_list(infile=infile, outfile=args.outfile,
|
||||
out_format=args.format, pattern=args.pattern)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
scene_list_cli()
|
||||
scene_list_cli()
|
||||
|
||||
Reference in New Issue
Block a user