Skip to content

Commit

Permalink
Merge pull request #11187 from isimluk/unused-code
Browse files Browse the repository at this point in the history
remove unused code
  • Loading branch information
jan-cerny authored Oct 10, 2023
2 parents a9a56a7 + 05a1e16 commit c0f250b
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions ssg/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ def add_minimum_version(ansible_src):
return ansible_src.replace(" - hosts: all", pre_task, 1)


def add_play_name(ansible_src, profile):
old_play_start = r"^( *)- hosts: all"
new_play_start = (
r"\1- name: Ansible Playbook for %s\n\1 hosts: all" % (profile))
return re.sub(old_play_start, new_play_start, ansible_src, flags=re.M)


def remove_too_many_blank_lines(ansible_src):
"""
Condenses three or more empty lines as two.
Expand All @@ -58,34 +51,3 @@ def remove_trailing_whitespace(ansible_src):
Removes trailing whitespace in an Ansible script
"""
return re.sub(r'[ \t]+$', '', ansible_src, 0, flags=re.M)


def strip_eof(ansible_src):
"""
Removes extra newlines at end of file
"""
return ansible_src.rstrip() + "\n"


def _strings_to_list(one_or_more_strings):
"""
Output a list, that either contains one string, or a list of strings.
In Python, strings can be cast to lists without error, but with unexpected result.
"""
if isinstance(one_or_more_strings, str):
return [one_or_more_strings]
else:
return list(one_or_more_strings)


def update_yaml_list_or_string(current_contents, new_contents):
result = []
if current_contents:
result += _strings_to_list(current_contents)
if new_contents:
result += _strings_to_list(new_contents)
if not result:
result = ""
if len(result) == 1:
result = result[0]
return result

0 comments on commit c0f250b

Please sign in to comment.