Skip to content

Commit f080e1f

Browse files
committed
Rename variables called raw_input
raw_input() is a Python built-in function; best not to shadow it.
1 parent 7583f39 commit f080e1f

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

python/phonenumbers/phonenumberutil.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,15 +1088,16 @@ def format_in_original_format(numobj, region_calling_from):
10881088
return format_number(numobj, PhoneNumberFormat.NATIONAL)
10891089

10901090
formatted_number = _format_original_allow_mods(numobj, region_calling_from)
1091-
raw_input = numobj.raw_input
1091+
num_raw_input = numobj.raw_input
10921092
# If no digit is inserted/removed/modified as a result of our formatting,
10931093
# we return the formatted phone number; otherwise we return the raw input
10941094
# the user entered.
1095-
if formatted_number is not None and len(raw_input) > 0:
1095+
if (formatted_number is not None and
1096+
num_raw_input is not None and len(num_raw_input) > 0):
10961097
normalized_formatted_number = _normalize_helper(formatted_number, _DIALLABLE_CHAR_MAPPINGS, True)
1097-
normalized_raw_input = _normalize_helper(raw_input, _DIALLABLE_CHAR_MAPPINGS, True)
1098+
normalized_raw_input = _normalize_helper(num_raw_input, _DIALLABLE_CHAR_MAPPINGS, True)
10981099
if normalized_formatted_number != normalized_raw_input:
1099-
formatted_number = raw_input
1100+
formatted_number = num_raw_input
11001101
return formatted_number
11011102

11021103

@@ -1221,43 +1222,43 @@ def format_out_of_country_keeping_alpha_chars(numobj, region_calling_from):
12211222
12221223
Returns the formatted phone number
12231224
"""
1224-
raw_input = numobj.raw_input
1225+
num_raw_input = numobj.raw_input
12251226
# If there is no raw input, then we can't keep alpha characters because there aren't any.
12261227
# In this case, we return format_out_of_country_calling_number.
1227-
if raw_input is None or len(raw_input) == 0:
1228+
if num_raw_input is None or len(num_raw_input) == 0:
12281229
return format_out_of_country_calling_number(numobj, region_calling_from)
12291230
country_code = numobj.country_code
12301231
if not _has_valid_country_calling_code(country_code):
1231-
return raw_input
1232+
return num_raw_input
12321233
# Strip any prefix such as country calling code, IDD, that was present. We
12331234
# do this by comparing the number in raw_input with the parsed number. To
12341235
# do this, first we normalize punctuation. We retain number grouping
12351236
# symbols such as " " only.
1236-
raw_input = _normalize_helper(raw_input,
1237-
_ALL_PLUS_NUMBER_GROUPING_SYMBOLS,
1238-
True)
1237+
num_raw_input = _normalize_helper(num_raw_input,
1238+
_ALL_PLUS_NUMBER_GROUPING_SYMBOLS,
1239+
True)
12391240
# Now we trim everything before the first three digits in the parsed
12401241
# number. We choose three because all valid alpha numbers have 3 digits at
12411242
# the start - if it does not, then we don't trim anything at
12421243
# all. Similarly, if the national number was less than three digits, we
12431244
# don't trim anything at all.
12441245
national_number = national_significant_number(numobj)
12451246
if len(national_number) > 3:
1246-
first_national_number_digit = raw_input.find(national_number[:3])
1247+
first_national_number_digit = num_raw_input.find(national_number[:3])
12471248
if first_national_number_digit != -1:
1248-
raw_input = raw_input[first_national_number_digit:]
1249+
num_raw_input = num_raw_input[first_national_number_digit:]
12491250

12501251
metadata_for_region_calling_from = PhoneMetadata.region_metadata.get(region_calling_from.upper(), None)
12511252
if country_code == _NANPA_COUNTRY_CODE:
12521253
if is_nanpa_country(region_calling_from):
1253-
return unicode(country_code) + u" " + raw_input
1254+
return unicode(country_code) + u" " + num_raw_input
12541255
elif (metadata_for_region_calling_from is not None and
12551256
country_code == country_code_for_region(region_calling_from)):
12561257
formatting_pattern = choose_formatting_pattern_for_number(metadata_for_region_calling_from.number_format,
12571258
national_number)
12581259
if formatting_pattern is None:
12591260
# If no pattern above is matched, we format the original input
1260-
return raw_input
1261+
return num_raw_input
12611262
new_format = NumberFormat()
12621263
new_format._mutable = True
12631264
new_format.merge_from(formatting_pattern)
@@ -1273,7 +1274,7 @@ def format_out_of_country_keeping_alpha_chars(numobj, region_calling_from):
12731274
# leading digits) decide whether a national prefix needs to be used,
12741275
# since we have overridden the pattern to match anything, but that is
12751276
# not the case in the metadata to date.
1276-
return format_nsn_using_pattern(raw_input,
1277+
return format_nsn_using_pattern(num_raw_input,
12771278
new_format,
12781279
PhoneNumberFormat.NATIONAL)
12791280
i18n_prefix_for_formatting = ""
@@ -1294,7 +1295,7 @@ def format_out_of_country_keeping_alpha_chars(numobj, region_calling_from):
12941295
formatted_number = _maybe_append_formatted_extension(numobj,
12951296
metadata_for_region,
12961297
PhoneNumberFormat.INTERNATIONAL,
1297-
raw_input)
1298+
num_raw_input)
12981299
if i18n_prefix_for_formatting is not None and len(i18n_prefix_for_formatting) > 0:
12991300
formatted_number = (i18n_prefix_for_formatting + u" " +
13001301
unicode(country_code) + u" " + formatted_number)

0 commit comments

Comments
 (0)