From e4736beab75bacba5bc29870c3ceb35e41c9f828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Fe=C5=99tek?= Date: Mon, 12 Oct 2020 11:24:12 +0200 Subject: [PATCH] Make validation optional ( https://github.com/singer-io/target-csv/pull/25 ) --- target_csv.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target_csv.py b/target_csv.py index 68a8994..b7dc309 100755 --- a/target_csv.py +++ b/target_csv.py @@ -50,7 +50,7 @@ def get_headers(schema, parent_key=DEFAULT_PARENT_KEY, sep=SEP): def generate_key(parent_key, sep, key): return parent_key + sep + key if parent_key else key -def persist_messages(delimiter, quotechar, messages, destination_path): +def persist_messages(delimiter, quotechar, messages, destination_path, validate_records): state = None schemas = {} key_properties = {} @@ -68,7 +68,8 @@ def persist_messages(delimiter, quotechar, messages, destination_path): raise Exception("A record for stream {}" "was encountered before a corresponding schema".format(o['stream'])) - validators[o['stream']].validate(o['record']) + if validate_records: + validators[o['stream']].validate(o['record']) filename = o['stream'] + '.csv' filename = os.path.expanduser(os.path.join(destination_path, filename)) @@ -144,7 +145,8 @@ def main(): state = persist_messages(config.get('delimiter', ','), config.get('quotechar', '"'), input_messages, - config.get('destination_path', '')) + config.get('destination_path', ''), + config.get('validate_records', True)) emit_state(state) logger.debug("Exiting normally")