<commit_before>"""A simple python library for getting caller ID name information."""


from re import sub

from slumber import API

from .errors import InvalidPhoneNumberError


class Phone(object):
    """An object that holds a single phone's information.

    :attr str OPENCNAM_API_URL: Current OpenCNAM API endpoint.
    :attr str number: The validated 10-digit US phone number.
    :attr str cnam: The caller ID name for this phone.
    """
    OPENCNAM_API_URL = 'https://api.opencnam.com/v1'

    def __init__(self, number):
        self.api = API(self.OPENCNAM_API_URL, append_slash=False)
        self.cnam = ''
        self.number = self._parse_number(str(number))

    def _parse_number(self, number):
        """Make ``number`` a valid phone number and return it.

        :param str number: Phone number in any format.
        :rtype: string
        :returns: A valid 10-digit US phone number as a string.
        :raises: InvalidPhoneNumberError if ``number`` cannot be made into a
            valid US phone number.

        Usage::

            from opencnam import Phone

            phone = Phone('+1-818-217-9229')
            assert phone.number == '8182179229'<commit_msg>Importing my temporary API class instead of Slumber's.<commit_after>"""A simple python library for getting caller ID name information."""


from re import sub


from .errors import InvalidPhoneNumberError
from .helpers import API


class Phone(object):
    """An object that holds a single phone's information.

    :attr str OPENCNAM_API_URL: Current OpenCNAM API endpoint.
    :attr str number: The validated 10-digit US phone number.
    :attr str cnam: The caller ID name for this phone.
    """
    OPENCNAM_API_URL = 'https://api.opencnam.com/v1'

    def __init__(self, number):
        self.api = API(self.OPENCNAM_API_URL, append_slash=False)
        self.cnam = ''
        self.number = self._parse_number(str(number))

    def _parse_number(self, number):
        """Make ``number`` a valid phone number and return it.

        :param str number: Phone number in any format.
        :rtype: string
        :returns: A valid 10-digit US phone number as a string.
        :raises: InvalidPhoneNumberError if ``number`` cannot be made into a
            valid US phone number.

        Usage::

            from opencnam import Phone

            phone = Phone('+1-818-217-9229')
            assert phone.number == '8182179229'
{'fraction_non_alphanumeric': 0.08937397034596375, 'fraction_numerical': 0.0214168039538715, 'mean_word_length': 2.714067278287462, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '617932', 'n_tokens_mistral': 738, 'n_tokens_neox': 672, 'n_words': 256}