From 40e4c697243ec571a82308b2680c16369ab6c412 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 11 Oct 2023 17:44:42 -0700 Subject: [PATCH] Cleanup the hacking directory a bit (#81960) * Clean up hacking/ansible-profile script Also rename the script so it has a `.py` extension. * Remove test-module symlink Use the test-module.py script instead. --- hacking/{ansible-profile => ansible-profile.py} | 12 +++++------- hacking/test-module | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) rename hacking/{ansible-profile => ansible-profile.py} (69%) delete mode 120000 hacking/test-module diff --git a/hacking/ansible-profile b/hacking/ansible-profile.py similarity index 69% rename from hacking/ansible-profile rename to hacking/ansible-profile.py index 9856e7ab5c9..7016ebe098c 100755 --- a/hacking/ansible-profile +++ b/hacking/ansible-profile.py @@ -1,24 +1,22 @@ #!/usr/bin/env python -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import cProfile import sys import traceback -import ansible.constants as C from ansible.module_utils.common.text.converters import to_text target = sys.argv.pop(1) myclass = "%sCLI" % target.capitalize() +module_name = f'ansible.cli.{target}' try: # define cli - mycli = getattr(__import__("ansible.cli.%s" % target, fromlist=[myclass]), myclass) + mycli = getattr(__import__(module_name, fromlist=[myclass]), myclass) except ImportError as e: - msg = getattr(e, 'msg', getattr(e, message, '')) - if msg.endswith(' %s' % target): - raise Exception("Ansible sub-program not implemented: %s" % target) + if module_name in e.msg: + raise Exception("Ansible sub-program not implemented: %s" % target) from None else: raise diff --git a/hacking/test-module b/hacking/test-module deleted file mode 120000 index 1deb52b4677..00000000000 --- a/hacking/test-module +++ /dev/null @@ -1 +0,0 @@ -test-module.py \ No newline at end of file