<commit_before>#!/usr/bin/python

# Add security groups to CloudFormation template files.
# This will modify the CloudFormation template files,

import sys, json, glob
from ansible.module_utils.basic import *
from cfyaml import yaml


def read_template(file_name):
    with open(file_name, 'r') as f:
        template = yaml.load(f)
    return template


def write_template(file_name, template):
    with open(file_name, 'w') as f:
        text = yaml.dump(template, default_flow_style=False)
        f.write(text)


def add_secgrps_to_elb(elb_resource, secgrps, template, debug_output):

    for resource in template['Resources']:
        if elb_resource in resource:
            elb_secgrps = template['Resources'][elb_resource]['Properties']['SecurityGroups']
            for secgrp in secgrps:
                elb_secgrps.append(secgrp)
                debug_output.append('Adding: ' + secgrp + ' to ' + elb_resource)

    return template


def main():

    module = AnsibleModule(
      argument_spec = dict(
        template_dir = dict(required=True, type='str'),
        elb_resource = dict(required=True, type='str'),
        secgrps = dict(required=True, type='list')
      )
    )

    # for debug text
    debug_output = []
<commit_msg>Disable debug_output<commit_after>#!/usr/bin/python

# Add security groups to CloudFormation template files.
# This will modify the CloudFormation template files,

import sys, json, glob
from ansible.module_utils.basic import *
from cfyaml import yaml


def read_template(file_name):
    with open(file_name, 'r') as f:
        template = yaml.load(f)
    return template


def write_template(file_name, template):
    with open(file_name, 'w') as f:
        text = yaml.dump(template, default_flow_style=False)
        f.write(text)


def add_secgrps_to_elb(elb_resource, secgrps, template, debug_output):

    for resource in template['Resources']:
        if elb_resource in resource:
            elb_secgrps = template['Resources'][elb_resource]['Properties']['SecurityGroups']
            for secgrp in secgrps:
                #debug_output.append('Adding: ' + secgrp + ' to ' + elb_resource)
                elb_secgrps.append(secgrp)

    return template


def main():

    module = AnsibleModule(
      argument_spec = dict(
        template_dir = dict(required=True, type='str'),
        elb_resource = dict(required=True, type='str'),
        secgrps = dict(required=True, type='list')
      )
    )

    # for debug text
    debug_output = []

{'fraction_non_alphanumeric': 0.10431654676258993, 'fraction_numerical': 0.0, 'mean_word_length': 3.1440397350993377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6788439', 'n_tokens_mistral': 785, 'n_tokens_neox': 760, 'n_words': 189}