Skip to content

Commit ae4a162

Browse files
committed
Merge branch 'dev' into python3
Conflicts: python/phonenumbers/phonenumbermatcher.py
2 parents 89f0ca5 + e455d45 commit ae4a162

3 files changed

Lines changed: 48 additions & 7 deletions

File tree

python/allcheck.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
import sys
3+
import re
4+
import glob
5+
6+
import phonenumbers
7+
8+
INTERNAL_FILES = ['phonenumbers/util.py',
9+
'phonenumbers/re_util.py',
10+
'phonenumbers/unicode_util.py']
11+
CLASS_RE = re.compile(r"^class +([A-Za-z][_A-Za-z0-9]+)[ \(:]")
12+
FUNCTION_RE = re.compile("^def +([A-Za-z][_A-Za-z0-9]+)[ \(]")
13+
CONSTANT_RE = re.compile("^([A-Z][_A-Z0-9]+) *= *")
14+
15+
grepped_all = set()
16+
for filename in glob.glob('phonenumbers/*.py'):
17+
if filename in INTERNAL_FILES:
18+
continue
19+
with file(filename, "r") as infile:
20+
for line in infile:
21+
m = CLASS_RE.match(line)
22+
if m:
23+
grepped_all.add(m.group(1))
24+
m = FUNCTION_RE.match(line)
25+
if m:
26+
grepped_all.add(m.group(1))
27+
m = CONSTANT_RE.match(line)
28+
if m:
29+
grepped_all.add(m.group(1))
30+
31+
code_all = set(phonenumbers.__all__)
32+
code_not_grepped = (code_all - grepped_all)
33+
grepped_not_code = (grepped_all - code_all)
34+
if len(code_not_grepped) > 0:
35+
print >> sys.stderr, "Found the following in __all__ but not in grepped code:"
36+
for identifier in code_not_grepped:
37+
print >> sys.stderr, " %s" % identifier
38+
if len(grepped_not_code) > 0:
39+
print >> sys.stderr, "Found the following in grepped code but not in__all__:"
40+
for identifier in grepped_not_code:
41+
print >> sys.stderr, " %s" % identifier

python/phonenumbers/geocoder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ def country_name_for_number(numobj, lang, script=None, region=None):
143143
Returns a text description in the given language code, for the given phone
144144
number's region, or an empty string if no description is available."""
145145
number_region = region_code_for_number(numobj)
146-
return region_display_name(number_region, lang, script, region)
146+
return _region_display_name(number_region, lang, script, region)
147147

148148

149-
def region_display_name(region_code, lang, script=None, region=None):
149+
def _region_display_name(region_code, lang, script=None, region=None):
150150
if region_code in LOCALE_DATA:
151151
# The Locale data has a set of names for this region, in various languages.
152152
name = LOCALE_DATA[region_code].get(lang, "")
@@ -206,7 +206,7 @@ def description_for_valid_number(numobj, lang, script=None, region=None):
206206
return country_name_for_number(numobj, lang, script, region)
207207
else:
208208
# Otherwise, we just show the region(country) name for now.
209-
return region_display_name(number_region, lang, script, region)
209+
return _region_display_name(number_region, lang, script, region)
210210
# TODO: Concatenate the lower-level and country-name information in an
211211
# appropriate way for each language.
212212

python/phonenumbers/phonenumbermatcher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def _limit(lower, upper):
117117

118118
# Matches timestamps. Examples: "2012-01-02 08:00". Note that the reg-ex does
119119
# not include the trailing ":\d\d" -- that is covered by TIME_STAMPS_SUFFIX.
120-
TIME_STAMPS = re.compile(u("[12]\\d{3}[-/]?[01]\\d[-/]?[0-3]\\d [0-2]\\d$"))
121-
TIME_STAMPS_SUFFIX = re.compile(u(":[0-5]\\d"))
120+
_TIME_STAMPS = re.compile(u("[12]\\d{3}[-/]?[01]\\d[-/]?[0-3]\\d [0-2]\\d$"))
121+
_TIME_STAMPS_SUFFIX = re.compile(u(":[0-5]\\d"))
122122

123123
# Matches white-space, which may indicate the end of a phone number and the
124124
# start of something else (such as a neighbouring zip-code). If white-space is
@@ -495,9 +495,9 @@ def _extract_match(self, candidate, offset):
495495
return None
496496

497497
# Skip potential time-stamps.
498-
if TIME_STAMPS.search(candidate):
498+
if _TIME_STAMPS.search(candidate):
499499
following_text = self.text[offset + len(candidate):]
500-
if TIME_STAMPS_SUFFIX.match(following_text):
500+
if _TIME_STAMPS_SUFFIX.match(following_text):
501501
return None
502502

503503
# Try to come up with a valid match given the entire candidate.

0 commit comments

Comments
 (0)