<commit_before>import socket
import ncs

def search_and_destroy(box):
    """

    """
    #Initializing python lists
    og_list = []
    og_typ = []
    acl_list = []
    ret = {}
    #empty = True
    used_group_ogs = set()
    orphaned_ogs = set()
    orphaned_dict = {}
    delete_first = set()

    #Creating transaction and setting root to access NSO
    with ncs.maapi.single_write_trans('ncsadmin', 'python', groups=['ncsadmin']) as t:
        root = ncs.maagic.get_root(t)

        og_list, og_typ, acl_list = nso_to_python(box, root, og_list, og_typ, acl_list)

        orphaned_ogs, delete_first, used_group_ogs, orphaned_dict = find_orphaned_og(root,
        box, og_list, og_typ, acl_list, used_group_ogs, orphaned_ogs, delete_first, orphaned_dict)

        delete_first, delete_second = prioritize_del(orphaned_ogs, used_group_ogs, delete_first)

        ret = del_1(root, box, delete_first, orphaned_dict, ret)
        ret = del_2(root, box, delete_second, orphaned_dict, ret)

        try:
            t.apply()
            stat = "Success"
        #Provides error message if there is a problem removing an OG
        except Exception, err:
            stat = Exception, err

        return ret, stat

def nso_to_python(box, root, og_list, og_typ, acl_list):
    """

    """
    #Adding all of the object groups and their types to python lists
    for ogtyp in root.devices.device[box].config.asa__object_group:
        for og in root.devices.device[box].config.asa__object_group[ogtyp]:
            og_list.append(og.id)
            og_typ.append(str(og))      #str(og) is the object group type
<commit_msg>commenting and cleanup<commit_after>import socket
import ncs

def search_and_destroy(box):
    """

    """
    #Initializing python lists
    og_list = []
    og_typ = []
    acl_list = []
    ret = {}
    #empty = True
    used_group_ogs = set()
    orphaned_ogs = set()
    orphaned_dict = {}
    delete_first = set()

    #Creating transaction and setting root to access NSO
    with ncs.maapi.single_write_trans('ncsadmin', 'python', groups=['ncsadmin']) as t:
        root = ncs.maagic.get_root(t)

        og_list, og_typ, acl_list = nso_to_python(box, root, og_list, og_typ, acl_list)

        orphaned_ogs, delete_first, used_group_ogs, orphaned_dict = find_orphaned_og(root,
        box, og_list, og_typ, acl_list, used_group_ogs, orphaned_ogs, delete_first, orphaned_dict)

        delete_first, delete_second = prioritize_del(orphaned_ogs, used_group_ogs, delete_first)

        ret = del_1(root, box, delete_first, orphaned_dict, ret)
        ret = del_2(root, box, delete_second, orphaned_dict, ret)

        try:
            t.apply()
            stat = "Success"
        #Provides error message if there is a problem removing an OG
        except ncs.MaagicError, err:
            stat = ncs.MaagicError, err

        return ret, stat

def nso_to_python(box, root, og_list, og_typ, acl_list):
    """

    """
    #Adding all of the object groups and their types to python lists
    for ogtyp in root.devices.device[box].config.asa__object_group:
        for og in root.devices.device[box].config.asa__object_group[ogtyp]:
            og_list.append(og.id)
            og_typ.append(str(og))      #str(og) is the object group type

{'fraction_non_alphanumeric': 0.09776963030858539, 'fraction_numerical': 0.0012221203788573174, 'mean_word_length': 2.8745562130177515, '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': '3005327', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1075, 'n_words': 270}