

def length_of_geographical_area_code(numobj):
    'Return length of the geographical area code for a number.\n\n    Gets the length of the geographical area code from the PhoneNumber object\n    passed in, so that clients could use it to split a national significant\n    number into geographical area code and subscriber number. It works in such\n    a way that the resultant subscriber number should be diallable, at least\n    on some devices. An example of how this could be used:\n\n    >>> import phonenumbers\n    >>> numobj = phonenumbers.parse("16502530000", "US")\n    >>> nsn = phonenumbers.national_significant_number(numobj)\n    >>> ac_len = phonenumbers.length_of_geographical_area_code(numobj)\n    >>> if ac_len > 0:\n    ...     area_code = nsn[:ac_len]\n    ...     subscriber_number = nsn[ac_len:]\n    ... else:\n    ...     area_code = ""\n    ...     subscriber_number = nsn\n\n    N.B.: area code is a very ambiguous concept, so the I18N team generally\n    recommends against using it for most purposes, but recommends using the\n    more general national_number instead. Read the following carefully before\n    deciding to use this method:\n\n     - geographical area codes change over time, and this method honors those\n       changes; therefore, it doesn\'t guarantee the stability of the result it\n       produces.\n     - subscriber numbers may not be diallable from all devices (notably\n       mobile devices, which typically require the full national_number to be\n       dialled in most countries).\n     - most non-geographical numbers have no area codes, including numbers\n       from non-geographical entities.\n     - some geographical numbers have no area codes.\n\n    Arguments:\n    numobj -- The PhoneNumber object to find the length of the area code form.\n\n    Returns the length of area code of the PhoneNumber object passed in.\n    '
    metadata = PhoneMetadata.metadata_for_region(region_code_for_number(numobj), None)
    if (metadata is None):
        return 0
    if ((metadata.national_prefix is None) and (not numobj.italian_leading_zero)):
        return 0
    if (not _is_number_geographical(numobj)):
        return 0
    return length_of_national_destination_code(numobj)

dataset/ETHPy150Open daviddrysdale/python-phonenumbers/python/phonenumbers/phonenumberutil.py length_of_geographical_area_code/original