<commit_before># Author: <NAME>
# Twitter: @j_cae
# 
# 
# This is a module of basic classes and functions that can be used to
# simplify the creation of NXAPI scripts.
#
#

import requests
import json
from getpass import getpass
from ipaddress import ip_address

class NXOS():
    '''
    This is a class to encapsulate the information needed to connect to
    an NXOS device via NXAPI.  The object is instantiated with an IP
    address and has setter methods to set credentials.  This class also
    leverages the "py2-ipaddress" module to verify valid IP address inputs.  
    '''

    def __init__(self, IP):
        self._ip = ip_address(IP)
        self._username = None
        self._password = None

    def __repr__(self):
        return "NXOS Device @ " + self.ip

    def __str__(self):
        return self.ip

    @property
    def username(self):
        return self._username    
    @username.setter
    def username(self, value):
        self._username = value
    
    @property
    def password(self):
        return self._password
    @password.setter
    def password(self, value):
        self._password = value

    @property
    def ip(self):
        return self._ip.exploded
    @ip.setter
    def ip(self, value):
        self._ip = ip_address(value)
    

    def PromptCreds(self):
        print "Please supply credentials for device: {}".format(str(self))
        user = raw_input('Username: ')
        if len(user) > 0:
            self.username = user<commit_msg>Fixed issue with newer ipaddress module<commit_after># Author: <NAME>
# Twitter: @j_cae
# 
# 
# This is a module of basic classes and functions that can be used to
# simplify the creation of NXAPI scripts.
#
#

import requests
import json
from getpass import getpass
from ipaddress import ip_address

class NXOS():
    '''
    This is a class to encapsulate the information needed to connect to
    an NXOS device via NXAPI.  The object is instantiated with an IP
    address and has setter methods to set credentials.  This class also
    leverages the "py2-ipaddress" module to verify valid IP address inputs.  
    '''

    def __init__(self, IP = None):
        self.ip = IP
        self.username = None
        self.password = <PASSWORD>

    def __repr__(self):
        return "NXOS Device @ " + self.ip

    def __str__(self):
        return self.ip

    @property
    def username(self):
        return self._username    
    @username.setter
    def username(self, value):
        self._username = value
    
    @property
    def password(self):
        return self._password
    @password.setter
    def password(self, value):
        self._password = value

    @property
    def ip(self):
        return self._ip
    @ip.setter
    def ip(self, value):
        if isinstance(value, unicode):
            self._ip = ip_address(ip)
        else:
            self._ip = ip_address(unicode(ip))


    def PromptCreds(self):
        print "Please supply credentials for device: {}".format(str(self))
        user = raw_input('Username: ')
        if len(user) > 0:
            self.username = user
{'fraction_non_alphanumeric': 0.0829567462879277, 'fraction_numerical': 0.0012911555842479018, 'mean_word_length': 2.394304490690033, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, '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': '4365295', 'n_tokens_mistral': 912, 'n_tokens_neox': 888, 'n_words': 315}