mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2026-01-01 17:30:47 +00:00
Tweaked validation behavior
This commit is contained in:
@@ -152,7 +152,8 @@ def convert(input_file, output_format='fmpxml', output=sys.stdout, warnings=True
|
|||||||
|
|
||||||
if warnings:
|
if warnings:
|
||||||
for warning in chain(validate_unique_field(lines,
|
for warning in chain(validate_unique_field(lines,
|
||||||
field='cue_number'),
|
field='cue_number',
|
||||||
|
scope='title'),
|
||||||
validate_non_empty_field(lines,
|
validate_non_empty_field(lines,
|
||||||
field='cue_number'),
|
field='cue_number'),
|
||||||
validate_non_empty_field(lines,
|
validate_non_empty_field(lines,
|
||||||
@@ -175,15 +176,3 @@ def convert(input_file, output_format='fmpxml', output=sys.stdout, warnings=True
|
|||||||
create_adr_reports(lines, tc_display_format=session_tc_format,
|
create_adr_reports(lines, tc_display_format=session_tc_format,
|
||||||
reel_list=sorted(reels))
|
reel_list=sorted(reels))
|
||||||
|
|
||||||
# elif output_format == 'csv':
|
|
||||||
# dump_csv(parsed['events'])
|
|
||||||
#
|
|
||||||
|
|
||||||
# elif output_format == 'fmpxml':
|
|
||||||
# if xsl is None:
|
|
||||||
# dump_fmpxml(parsed, input_file, output, adr_field_map)
|
|
||||||
# else:
|
|
||||||
# print_section_header_style("Performing XSL Translation")
|
|
||||||
# print_status_style("Using builtin translation: %s" % xsl)
|
|
||||||
# fmp_transformed_dump(parsed, input_file, xsl, output)
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,14 +29,20 @@ def validate_value(input_lines: Iterator[ADRLine], key_field, predicate):
|
|||||||
event=event)
|
event=event)
|
||||||
|
|
||||||
|
|
||||||
def validate_unique_field(input_lines: Iterator[ADRLine], field='cue_number'):
|
def validate_unique_field(input_lines: Iterator[ADRLine], field='cue_number', scope=None):
|
||||||
values = set()
|
values = dict()
|
||||||
for event in input_lines:
|
for event in input_lines:
|
||||||
this = getattr(event, field)
|
this = getattr(event, field)
|
||||||
if this in values:
|
if scope is not None:
|
||||||
|
key = getattr(event, scope)
|
||||||
|
else:
|
||||||
|
key = '_values'
|
||||||
|
|
||||||
|
values.setdefault(key, set())
|
||||||
|
if this in values[key]:
|
||||||
yield ValidationError(message='Re-used {}'.format(field), event=event)
|
yield ValidationError(message='Re-used {}'.format(field), event=event)
|
||||||
else:
|
else:
|
||||||
values.update(this)
|
values[key].update(this)
|
||||||
|
|
||||||
|
|
||||||
def validate_non_empty_field(input_lines: Iterator[ADRLine], field='cue_number'):
|
def validate_non_empty_field(input_lines: Iterator[ADRLine], field='cue_number'):
|
||||||
|
|||||||
Reference in New Issue
Block a user