

def format_out_of_country_keeping_alpha_chars(numobj, region_calling_from):
    'Formats a phone number for out-of-country dialing purposes.\n\n    Note that in this version, if the number was entered originally using\n    alpha characters and this version of the number is stored in raw_input,\n    this representation of the number will be used rather than the digit\n    representation. Grouping information, as specified by characters such as\n    "-" and " ", will be retained.\n\n    Caveats:\n\n     - This will not produce good results if the country calling code is both\n       present in the raw input _and_ is the start of the national\n       number. This is not a problem in the regions which typically use alpha\n       numbers.\n\n     - This will also not produce good results if the raw input has any\n       grouping information within the first three digits of the national\n       number, and if the function needs to strip preceding digits/words in\n       the raw input before these digits. Normally people group the first\n       three digits together so this is not a huge problem - and will be fixed\n       if it proves to be so.\n\n    Arguments:\n    numobj -- The phone number that needs to be formatted.\n    region_calling_from -- The region where the call is being placed.\n\n    Returns the formatted phone number\n    '
    num_raw_input = numobj.raw_input
    if ((num_raw_input is None) or (len(num_raw_input) == 0)):
        return format_out_of_country_calling_number(numobj, region_calling_from)
    country_code = numobj.country_code
    if (not _has_valid_country_calling_code(country_code)):
        return num_raw_input
    num_raw_input = _normalize_helper(num_raw_input, _ALL_PLUS_NUMBER_GROUPING_SYMBOLS, True)
    national_number = national_significant_number(numobj)
    if (len(national_number) > 3):
        first_national_number_digit = num_raw_input.find(national_number[:3])
        if (first_national_number_digit != (- 1)):
            num_raw_input = num_raw_input[first_national_number_digit:]
    metadata_for_region_calling_from = PhoneMetadata.metadata_for_region(region_calling_from.upper(), None)
    if (country_code == _NANPA_COUNTRY_CODE):
        if is_nanpa_country(region_calling_from):
            return ((unicod(country_code) + U_SPACE) + num_raw_input)
    elif ((numobj is not None) and (country_code == country_code_for_region(region_calling_from))):
        formatting_pattern = _choose_formatting_pattern_for_number(metadata_for_region_calling_from.number_format, national_number)
        if (formatting_pattern is None):
            return num_raw_input
        new_format = _copy_number_format(formatting_pattern)
        new_format.pattern = u('(\\d+)(.*)')
        new_format.format = u('\\1\\2')
        return _format_nsn_using_pattern(num_raw_input, new_format, PhoneNumberFormat.NATIONAL)
    i18n_prefix_for_formatting = U_EMPTY_STRING
    if (metadata_for_region_calling_from is not None):
        international_prefix = metadata_for_region_calling_from.international_prefix
        i18n_match = fullmatch(_UNIQUE_INTERNATIONAL_PREFIX, international_prefix)
        if i18n_match:
            i18n_prefix_for_formatting = international_prefix
        else:
            i18n_prefix_for_formatting = metadata_for_region_calling_from.preferred_international_prefix
    region_code = region_code_for_country_code(country_code)
    metadata_for_region = PhoneMetadata.metadata_for_region_or_calling_code(country_code, region_code)
    formatted_number = _maybe_append_formatted_extension(numobj, metadata_for_region, PhoneNumberFormat.INTERNATIONAL, num_raw_input)
    if ((i18n_prefix_for_formatting is not None) and (len(i18n_prefix_for_formatting) > 0)):
        formatted_number = ((((i18n_prefix_for_formatting + U_SPACE) + unicod(country_code)) + U_SPACE) + formatted_number)
    else:
        formatted_number = _prefix_number_with_country_calling_code(country_code, PhoneNumberFormat.INTERNATIONAL, formatted_number)
    return formatted_number

dataset/ETHPy150Open daviddrysdale/python-phonenumbers/python/phonenumbers/phonenumberutil.py format_out_of_country_keeping_alpha_chars/VarMisuse@186/836 `metadata_for_region_calling_from`->`numobj`