From 587b388cb61929f103e10e625b3eb8d49d2279de Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 28 Dec 2023 20:20:36 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- reproschema/redcap2reproschema.py | 12 ++++++++---- reproschema/tests/test_redcap2reproschema.py | 15 +++++++-------- templates/redcap2rs.yaml | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/reproschema/redcap2reproschema.py b/reproschema/redcap2reproschema.py index 03a8e54..fe8a80e 100644 --- a/reproschema/redcap2reproschema.py +++ b/reproschema/redcap2reproschema.py @@ -475,15 +475,18 @@ def redcap2reproschema( protocol_visibility_obj, ) + def main(): - 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() # Read the YAML configuration with open(args.yaml_file, "r") as f: - protocol = yaml.safe_load(f) + protocol = yaml.safe_load(f) protocol_name = protocol.get("protocol_name") protocol_display_name = protocol.get("protocol_display_name") @@ -492,7 +495,7 @@ def main(): if not protocol_name: raise ValueError("Protocol name not specified in the YAML file.") - protocol_name = protocol_name.replace(' ', '_') # Replacing spaces with underscores + protocol_name = protocol_name.replace(" ", "_") # Replacing spaces with underscores # Check if the directory already exists if not os.path.exists(protocol_name): @@ -510,5 +513,6 @@ def main(): protocol_description, ) + if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/reproschema/tests/test_redcap2reproschema.py b/reproschema/tests/test_redcap2reproschema.py index 776f0e6..de2f630 100644 --- a/reproschema/tests/test_redcap2reproschema.py +++ b/reproschema/tests/test_redcap2reproschema.py @@ -7,12 +7,9 @@ # Assuming your test files are located in a 'tests' directory CSV_FILE_NAME = "redcap_dict.csv" YAML_FILE_NAME = "redcap2rs.yaml" -CSV_TEST_FILE = os.path.join( - os.path.dirname(__file__), "test_data", CSV_FILE_NAME -) -YAML_TEST_FILE = os.path.join( - os.path.dirname(__file__), "test_data", YAML_FILE_NAME -) +CSV_TEST_FILE = os.path.join(os.path.dirname(__file__), "test_data", CSV_FILE_NAME) +YAML_TEST_FILE = os.path.join(os.path.dirname(__file__), "test_data", YAML_FILE_NAME) + def test_redcap2reproschema_success(): runner = CliRunner() @@ -23,6 +20,8 @@ def test_redcap2reproschema_success(): shutil.copy(YAML_TEST_FILE, YAML_FILE_NAME) # Run the command within the isolated filesystem - result = runner.invoke(main, ['redcap2reproschema', CSV_FILE_NAME, YAML_FILE_NAME]) + result = runner.invoke( + main, ["redcap2reproschema", CSV_FILE_NAME, YAML_FILE_NAME] + ) print(result.output) - assert result.exit_code == 0 \ No newline at end of file + assert result.exit_code == 0 diff --git a/templates/redcap2rs.yaml b/templates/redcap2rs.yaml index 262ee1c..1e1dbc3 100644 --- a/templates/redcap2rs.yaml +++ b/templates/redcap2rs.yaml @@ -11,4 +11,4 @@ protocol_display_name: "Your protocol display name" # Protocol Description: # Provide a brief description of your protocol. -protocol_description: "Description for your protocol" # Example: "This protocol is for ..." \ No newline at end of file +protocol_description: "Description for your protocol" # Example: "This protocol is for ..."