#NEWLINE# def parse_phone_number( number , region = None , failhard = True ) : #NEWLINE# #INDENT# from phonenumbers.phonenumberutil import parse as phonenumbers_parse , NumberParseException #NEWLINE# try : #NEWLINE# #INDENT# phone = phonenumbers_parse ( number , region ) #NEWLINE# if phone : #NEWLINE# #INDENT# return PhoneNumber ( phone . country_code , phone . national_number ) #NEWLINE# #UNINDENT# #UNINDENT# except NumberParseException : #NEWLINE# #INDENT# if failhard : #NEWLINE# #INDENT# raise PhoneNumberParseException ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None