From 347c393ffcc8792756d964d772547827c7903048 Mon Sep 17 00:00:00 2001 From: hejamu Date: Thu, 21 Mar 2024 15:25:00 +0100 Subject: [PATCH 1/6] Fix lowercase names --- src/mdacli/cli.py | 3 --- src/mdacli/libcli.py | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mdacli/cli.py b/src/mdacli/cli.py index 248bad6..46b8079 100644 --- a/src/mdacli/cli.py +++ b/src/mdacli/cli.py @@ -102,9 +102,6 @@ def cli(name, # sub parser in complete detail. setup_clients(ap, title=f"{name} Analysis Modules", members=modules) - # Be case insensitive for the subcommand - sys.argv[1] = sys.argv[1].lower() - args = ap.parse_args() if args.debug: diff --git a/src/mdacli/libcli.py b/src/mdacli/libcli.py index cb7caa6..5323a7b 100644 --- a/src/mdacli/libcli.py +++ b/src/mdacli/libcli.py @@ -367,6 +367,7 @@ def create_cli(sub_parser, interface_name, parameters): # creates the subparser analysis_class_parser = sub_parser.add_parser( interface_name, + aliases=[interface_name.lower()], help=parameters["desc"], description=f"{parameters['desc']}\n\n{parameters['desc_long']}", formatter_class=argparse.RawDescriptionHelpFormatter, From 4a34e331b6d93ede8480d56a3fe5f973139549b4 Mon Sep 17 00:00:00 2001 From: hejamu Date: Thu, 21 Mar 2024 15:29:09 +0100 Subject: [PATCH 2/6] Default name to case sensitve --- src/mdacli/cli.py | 2 +- src/mdacli/libcli.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mdacli/cli.py b/src/mdacli/cli.py index 46b8079..5803309 100644 --- a/src/mdacli/cli.py +++ b/src/mdacli/cli.py @@ -117,7 +117,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/src/mdacli/libcli.py b/src/mdacli/libcli.py index 5323a7b..a2b8ade 100644 --- a/src/mdacli/libcli.py +++ b/src/mdacli/libcli.py @@ -767,7 +767,7 @@ def setup_clients(ap, title, members): # to be writen for member_name, parameters in analysis_interfaces.items(): create_cli(sub_parser=cli_subparser, - interface_name=member_name.lower(), + interface_name=member_name, parameters=parameters) From ffd0a807f2b52d0233135068cecddf9374f9ce6d Mon Sep 17 00:00:00 2001 From: hejamu Date: Thu, 21 Mar 2024 15:48:03 +0100 Subject: [PATCH 3/6] Add note on lowercase module names --- src/mdacli/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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`. From 67bdceb564af6bbf0e2144ee081c89a61cd0aba7 Mon Sep 17 00:00:00 2001 From: hejamu Date: Thu, 21 Mar 2024 15:52:06 +0100 Subject: [PATCH 4/6] Changelog --- docs/CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index b8716e3..f067ff2 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -2,11 +2,11 @@ Changelog ========= +* Change handling of lowercase module names v0.1.28 (2023-09-29) ------------------------------------------ - * Make choices style parsable (#114) v0.1.27 (2023-08-25) From 37f4e27028348a89476a07a83e7b894622630832 Mon Sep 17 00:00:00 2001 From: hejamu Date: Thu, 21 Mar 2024 15:56:23 +0100 Subject: [PATCH 5/6] Add test --- tests/test_cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index ae50aa8..83c11a6 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -36,6 +36,12 @@ def test_case_insensitive(args): """Test for beeing case insensitive.""" 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.""" From 682c07c91d11e789c87f935ac2621ea4bc4a1f28 Mon Sep 17 00:00:00 2001 From: hejamu Date: Thu, 21 Mar 2024 15:57:25 +0100 Subject: [PATCH 6/6] lint --- tests/test_cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 83c11a6..cde45b3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -36,6 +36,7 @@ def test_case_insensitive(args): """Test for beeing case insensitive.""" 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."""