<commit_before>#!/usr/bin/env python
from __future__ import print_function
import pyeapi
import argparse


def get_config(connection):
    config = connection.get_config(as_string=True)
    return(config)

def check_vlan(config,vlan_id):
    pattern = 'vlan ' + vlan_id
    vlan_conf = re.search(r'\b%s\b' % pattern, config)
    if vlan_conf:
        status = True
    else:
        status = False
    return(status)

def create_vlan(connection,vlan_id,vlan_name):
    connection.enable("vlan %s" % vlan_id, "name %s" % vlan_name)

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--name", type=str, default="")
    parser.add_argument("vlan", type=str)
    parser.add_argument("--remove", action="store_true", default=False)
    args = parser.parse_args()

    vlan_id = args.vlan
    vlan_name = args.name
    pynet_sw2 = pyeapi.connect_to('pynet-sw2')
    config = get_config(pynet_sw2)

    print("Checking for VLAN...")
    status = check_vlan(config,vlan_id)
    if status = False:
        print("No VLAN found.")
        #create_vlan(pynet_sw2,vlan_id, vlan_name)
        #print("\nVLAN has been created.")
    else:
        print("This VLAN is currently in use.")

if __name__ == "__main__":
    main()

<commit_msg>Ex2 changes.<commit_after>#!/usr/bin/env python
from __future__ import print_function
import pyeapi
import argparse
import re


def get_config(connection):
    config = connection.get_config(as_string=True)
    return(config)

def check_vlan(config,vlan_id):
    pattern = 'vlan ' + vlan_id
    vlan_conf = re.search(r'\b%s\b' % pattern, config)
    if vlan_conf:
        status = True
    else:
        status = False
    return(status)

def create_vlan(connection,vlan_id,vlan_name):
    connection.enable("vlan %s" % vlan_id, "name %s" % vlan_name)

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--name", type=str, default="")
    parser.add_argument("vlan", type=str)
    parser.add_argument("--remove", action="store_true", default=False)
    args = parser.parse_args()

    print(args.name)
    print(args.vlan)
    print(args.remove)

    vlan_id = args.vlan
    vlan_name = args.name
    pynet_sw2 = pyeapi.connect_to('pynet-sw2')
    config = get_config(pynet_sw2)

    print("Checking for VLAN...")
    status = check_vlan(config,vlan_id)
    if status == False:
        print("No VLAN found.")
        #create_vlan(pynet_sw2,vlan_id, vlan_name)
        #print("\nVLAN has been created.")
    else:
        print("This VLAN is currently in use.")

if __name__ == "__main__":
    main()


{'fraction_non_alphanumeric': 0.1291698991466253, 'fraction_numerical': 0.0034910783553141972, 'mean_word_length': 3.3860544217687076, 'pattern_counts': {'":': 2, '<': 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': '1943891', 'n_tokens_mistral': 930, 'n_tokens_neox': 921, 'n_words': 186}