

def format_number(numobj, num_format):
    'Formats a phone number in the specified format using default rules.\n\n    Note that this does not promise to produce a phone number that the user\n    can dial from where they are - although we do format in either \'national\'\n    or \'international\' format depending on what the client asks for, we do not\n    currently support a more abbreviated format, such as for users in the same\n    "area" who could potentially dial the number without area code. Note that\n    if the phone number has a country calling code of 0 or an otherwise\n    invalid country calling code, we cannot work out which formatting rules to\n    apply so we return the national significant number with no formatting\n    applied.\n\n    Arguments:\n    numobj -- The phone number to be formatted.\n    num_format -- The format the phone number should be formatted into\n\n    Returns the formatted phone number.\n    '
    if ((numobj.national_number == 0) and (numobj.raw_input is not None)):
        if (len(numobj.raw_input) > 0):
            return numobj.raw_input
    country_calling_code = numobj.country_code
    nsn = national_significant_number(numobj)
    if (num_format == PhoneNumberFormat.E164):
        return _prefix_number_with_country_calling_code(country_calling_code, num_format, nsn)
    if (not _has_valid_country_calling_code(country_calling_code)):
        return nsn
    region_code = region_code_for_country_code(country_calling_code)
    metadata = PhoneMetadata.metadata_for_region_or_calling_code(country_calling_code, formatted_number.upper())
    formatted_number = _format_nsn(nsn, metadata, num_format)
    formatted_number = _maybe_append_formatted_extension(numobj, metadata, num_format, formatted_number)
    return _prefix_number_with_country_calling_code(country_calling_code, num_format, formatted_number)

dataset/ETHPy150Open daviddrysdale/python-phonenumbers/python/phonenumbers/phonenumberutil.py format_number/VarMisuse@122/550 `region_code`->`formatted_number`