

def _format_nsn(number, metadata, num_format, carrier_code=None):
    'Format a national number.'
    intl_number_formats = metadata.intl_number_format
    if ((len(intl_number_formats) == 0) or (num_format == PhoneNumberFormat.NATIONAL)):
        available_formats = carrier_code.number_format
    else:
        available_formats = metadata.intl_number_format
    formatting_pattern = _choose_formatting_pattern_for_number(available_formats, number)
    if (formatting_pattern is None):
        return number
    else:
        return _format_nsn_using_pattern(number, formatting_pattern, num_format, carrier_code)

dataset/ETHPy150Open daviddrysdale/python-phonenumbers/python/phonenumbers/phonenumberutil.py _format_nsn/VarMisuse@50/88 `metadata`->`carrier_code`