From 4906d7606975b3ff2f4192e2983c2c9b8d2e623f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:11:58 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- reproschema/cli.py | 5 +++-- reproschema/redcap2reproschema.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/reproschema/cli.py b/reproschema/cli.py index 88655e5..663ce56 100644 --- a/reproschema/cli.py +++ b/reproschema/cli.py @@ -98,9 +98,10 @@ def serve(port): start_server(port=port) + @main.command() -@click.argument('csv_path', type=click.Path(exists=True, dir_okay=False)) -@click.argument('yaml_path', type=click.Path(exists=True, dir_okay=False)) +@click.argument("csv_path", type=click.Path(exists=True, dir_okay=False)) +@click.argument("yaml_path", type=click.Path(exists=True, dir_okay=False)) def redcap2reproschema(csv_path, yaml_path): """ Convert REDCap CSV files to Reproschema format. diff --git a/reproschema/redcap2reproschema.py b/reproschema/redcap2reproschema.py index c08c6b1..de24ae9 100644 --- a/reproschema/redcap2reproschema.py +++ b/reproschema/redcap2reproschema.py @@ -8,6 +8,7 @@ import yaml from bs4 import BeautifulSoup + def normalize_condition(condition_str): re_parentheses = re.compile(r"\(([0-9]*)\)") re_non_gt_lt_equal = re.compile(r"([^>|<])=") @@ -451,9 +452,13 @@ def redcap2reproschema(csv_path, yaml_path, schema_context_url=None): protocol_visibility_obj, ) + def main(): import argparse - parser = argparse.ArgumentParser(description="Convert REDCap data dictionary to Reproschema format.") + + parser = argparse.ArgumentParser( + description="Convert REDCap data dictionary to Reproschema format." + ) parser.add_argument("csv_file", help="Path to the REDCap data dictionary CSV file.") parser.add_argument("yaml_file", help="Path to the Reproschema protocol YAML file.") args = parser.parse_args() @@ -475,5 +480,6 @@ def main(): # Call the main conversion function redcap2reproschema(args.csv_file, args.yaml_file) + if __name__ == "__main__": - main() \ No newline at end of file + main()