mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-20 03:40:22 -07:00
Improve ansible-test python interpreter selection. (#54445)
This commit is contained in:
parent
3637ce4538
commit
785afc7a53
10 changed files with 203 additions and 99 deletions
|
@ -38,7 +38,8 @@ except ImportError:
|
|||
# noinspection PyCompatibility
|
||||
from configparser import ConfigParser
|
||||
|
||||
DOCKER_COMPLETION = {}
|
||||
DOCKER_COMPLETION = {} # type: dict[str, dict[str, str]]
|
||||
REMOTE_COMPLETION = {} # type: dict[str, dict[str, str]]
|
||||
PYTHON_PATHS = {} # type: dict[str, str]
|
||||
|
||||
try:
|
||||
|
@ -66,17 +67,33 @@ MODE_DIRECTORY_WRITE = MODE_DIRECTORY | stat.S_IWGRP | stat.S_IWOTH
|
|||
|
||||
def get_docker_completion():
|
||||
"""
|
||||
:rtype: dict[str, str]
|
||||
:rtype: dict[str, dict[str, str]]
|
||||
"""
|
||||
if not DOCKER_COMPLETION:
|
||||
images = read_lines_without_comments('test/runner/completion/docker.txt', remove_blank_lines=True)
|
||||
|
||||
DOCKER_COMPLETION.update(dict(kvp for kvp in [parse_docker_completion(i) for i in images] if kvp))
|
||||
|
||||
return DOCKER_COMPLETION
|
||||
return get_parameterized_completion(DOCKER_COMPLETION, 'docker')
|
||||
|
||||
|
||||
def parse_docker_completion(value):
|
||||
def get_remote_completion():
|
||||
"""
|
||||
:rtype: dict[str, dict[str, str]]
|
||||
"""
|
||||
return get_parameterized_completion(REMOTE_COMPLETION, 'remote')
|
||||
|
||||
|
||||
def get_parameterized_completion(cache, name):
|
||||
"""
|
||||
:type cache: dict[str, dict[str, str]]
|
||||
:type name: str
|
||||
:rtype: dict[str, dict[str, str]]
|
||||
"""
|
||||
if not cache:
|
||||
images = read_lines_without_comments('test/runner/completion/%s.txt' % name, remove_blank_lines=True)
|
||||
|
||||
cache.update(dict(kvp for kvp in [parse_parameterized_completion(i) for i in images] if kvp))
|
||||
|
||||
return cache
|
||||
|
||||
|
||||
def parse_parameterized_completion(value):
|
||||
"""
|
||||
:type value: str
|
||||
:rtype: tuple[str, dict[str, str]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue