#NEWLINE# def is_valid_short_number_for_region( short_number , region_dialing_from ) : #NEWLINE# #INDENT# "Tests whether a short number matches a valid pattern in a region.\n\n    Note that this doesn't verify the number is actually in use, which is\n    impossible to tell by just looking at the number itself.\n\n    Arguments:\n    short_number -- the short number to check as a PhoneNumber object or as\n              a string.  (The string variant is deprecated, and will be\n              removed in the next release.)\n    region_dialing_from -- the region from which the number is dialed\n\n    Return whether the short number matches a valid pattern\n    " #NEWLINE# if isinstance ( short_number , PhoneNumber ) : #NEWLINE# #INDENT# short_number = national_significant_number ( short_number ) #NEWLINE# #UNINDENT# metadata = PhoneMetadata . short_metadata_for_region ( region_dialing_from ) #NEWLINE# if ( metadata is None ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# general_desc = metadata . general_desc #NEWLINE# if ( ( general_desc . national_number_pattern is None ) or ( not _is_number_matching_desc ( short_number , general_desc ) ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# short_number_desc = metadata . short_code #NEWLINE# if ( short_number_desc . national_number_pattern is None ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return _is_number_matching_desc ( short_number , short_number_desc )