@@ -32,10 +32,6 @@ class Utilities:
32
32
Methods that may be useful, that have nothing to do with Selenium.
33
33
"""
34
34
35
- # COUNTRY_CODES = {
36
- # "US": "1", "CA": "1", "FR": "33", "DE": "49", "UK": "44", "JP": "81"
37
- # }
38
-
39
35
def __init__ (self ):
40
36
self .state_province_abbr = {
41
37
# US States
@@ -497,10 +493,9 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
497
493
"DE" : "49" ,
498
494
}
499
495
500
- # Remove phone number extensions (e.g., "x555" or "ext 555")
496
+ # Sub out anything that matches this regex statement with an empty string to get rid of extensions in generated phone numbers
501
497
phone = re .sub (r"\s*(?:x|ext)\s*\d*$" , "" , phone , flags = re .IGNORECASE )
502
-
503
- # Remove all non-numeric characters
498
+ # Sub out anything that is not a digit with the empty string to ensure the phone number is formatted with no spaces or special characters
504
499
digits = re .sub (r"\D" , "" , phone )
505
500
506
501
# Determine country code
@@ -511,12 +506,14 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
511
506
for code in country_codes .values ():
512
507
if digits .startswith (code ):
513
508
country_code = code
514
- local_number = digits [len (code ):] # Remove country code from local number
509
+ # Remove country code from local number
510
+ local_number = digits [len (code ):]
515
511
break
516
512
517
513
# Handle leading zero in local numbers (France & Germany)
518
514
if region in ["FR" , "DE" ] and local_number .startswith ("0" ):
519
- local_number = local_number [1 :] # Remove the leading zero
515
+ # Remove the leading zero
516
+ local_number = local_number [1 :]
520
517
521
518
# Validate local number length
522
519
if len (local_number ) < 6 : # Too short to be valid
0 commit comments