From 7d93b486bf86359bee2d6782d762c8321e5a6114 Mon Sep 17 00:00:00 2001 From: Henrik Stooss Date: Thu, 21 Mar 2024 16:03:35 +0100 Subject: [PATCH] Fix lowercase names (#117) --- docs/CHANGELOG.rst | 1 + src/mdacli/__main__.py | 5 +++-- src/mdacli/cli.py | 2 +- tests/test_cli.py | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index 7fc5357..860b78f 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog * Replace Boolean ``debug`` option in ``setup_logging`` by more flexible integer ``level`` parameter. +* Change handling of lowercase module names v0.1.28 (2023-09-29) ------------------------------------------ diff --git a/src/mdacli/__main__.py b/src/mdacli/__main__.py index 1c41c1e..d92f262 100644 --- a/src/mdacli/__main__.py +++ b/src/mdacli/__main__.py @@ -10,8 +10,9 @@ A command line interface (CLI) to the analysis modules of MDAnalysis. The modules are all structured as part of a single mdacli wrapper, and invoked -with commands like `mda RMSD`. This command uses the class -:class:`MDAnalysis.analysis.rms.RMSD` for calculating the RMSD. +with commands like `mda RMSD` (The lowercase `mda rmsd` is also supported). +This command uses the class :class:`MDAnalysis.analysis.rms.RMSD` for +calculating the RMSD. Documentation for each module can be found at the respective sections on the `MDAnalysis Documentation`_, as well as `mda command -h`. diff --git a/src/mdacli/cli.py b/src/mdacli/cli.py index 34ad039..db00d81 100644 --- a/src/mdacli/cli.py +++ b/src/mdacli/cli.py @@ -124,7 +124,7 @@ def cli(name, # Get the correct ArgumentParser instance from all subparsers # `[0]` selects the first subparser where our analysises live in. - _key = analysis_callable.__name__.lower() + _key = analysis_callable.__name__ ap_sup = ap._subparsers._group_actions[0].choices[_key] arg_grouped_dict = split_argparse_into_groups(ap_sup, args) diff --git a/tests/test_cli.py b/tests/test_cli.py index 45ea68c..8e37446 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -37,6 +37,13 @@ def test_case_insensitive(args): subprocess.check_call(["mda", args, "-h"]) +@pytest.mark.parametrize('args', ("RMSF", "rmsf")) +def test_case_insensitive_with_flags(args): + """Test for module name being case insensitive with additional flags.""" + # Check if it still works if the module name is not the second argument + subprocess.check_call(['mda', '--debug', args, "-h"]) + + def test_running_analysis(tmpdir): """Test running a complete analysis.""" with tmpdir.as_cwd():