@@ -27,7 +27,7 @@ def update_mask(mask, length):
27
27
while len (pn_mask .replace (" " , "" )) > pn_mask_expected_length :
28
28
pn_mask = pn_mask [:- 1 ]
29
29
mask = f"{ cc_mask } { ac_mask } { pn_mask } " if ac_mask else f"{ cc_mask } { pn_mask } "
30
- return re .sub (r"\s(\.{1,2} )$" , r"\1" , mask )
30
+ return re .sub (r"\s(\.)$" , r"\1" , mask )
31
31
32
32
33
33
with open (patterns_path ) as fp :
@@ -36,9 +36,10 @@ def update_mask(mask, length):
36
36
with open (countries_path ) as fp :
37
37
countries = json .load (fp )
38
38
39
- for territory in territories :
39
+ for territory in filter ( lambda t : t . get ( "id" ). isalpha (), territories ) :
40
40
# Regenerate masks based on possible maximum lengths
41
- possible_lengths = map (lambda e : territory .find (f"{ e .tag } /possibleLengths" ), territory .iter ())
41
+ possible_lengths = map (lambda e : territory .find (f"{ e .tag } /possibleLengths" ) if e .tag != "tollFree" else None ,
42
+ territory .iter ())
42
43
possible_lengths = map (lambda e : e .get ("national" ), filter (lambda e : e is not None , possible_lengths ))
43
44
possible_lengths = list (map (int , re .findall (r"\d+" , "," .join (possible_lengths ))))
44
45
min_length , max_length = min (possible_lengths ), max (possible_lengths )
0 commit comments