mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
Support comments in ansible-test flat files.
This commit is contained in:
parent
cb4bf04be6
commit
5a3000af19
13 changed files with 135 additions and 96 deletions
|
@ -42,8 +42,7 @@ def get_docker_completion():
|
|||
:rtype: dict[str, str]
|
||||
"""
|
||||
if not DOCKER_COMPLETION:
|
||||
with open('test/runner/completion/docker.txt', 'r') as completion_fd:
|
||||
images = completion_fd.read().splitlines()
|
||||
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))
|
||||
|
||||
|
@ -81,6 +80,23 @@ def remove_file(path):
|
|||
os.remove(path)
|
||||
|
||||
|
||||
def read_lines_without_comments(path, remove_blank_lines=False):
|
||||
"""
|
||||
:type path: str
|
||||
:type remove_blank_lines: bool
|
||||
:rtype: list[str]
|
||||
"""
|
||||
with open(path, 'r') as path_fd:
|
||||
lines = path_fd.read().splitlines()
|
||||
|
||||
lines = [re.sub(r' *#.*$', '', line) for line in lines]
|
||||
|
||||
if remove_blank_lines:
|
||||
lines = [line for line in lines if line]
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
def find_executable(executable, cwd=None, path=None, required=True):
|
||||
"""
|
||||
:type executable: str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue