Permalink
Browse files

More u() instances

  • Loading branch information...
1 parent 649b698 commit 59f4e2fef03c0c2a4a8d45c405dd66c9d493bc44 @daviddrysdale committed Nov 26, 2011
Showing with 12 additions and 10 deletions.
  1. +1 −1 python/phonenumbers/phonenumberutil.py
  2. +3 −2 python/phonenumbers/re_util.py
  3. +8 −7 python/phonenumbers/unicode_util.py
@@ -1113,7 +1113,7 @@ def format_out_of_country_keeping_alpha_chars(numobj, region_calling_from):
new_format.pattern = u("(\\d+)(.*)")
# Here we just concatenate them back together after the national
# prefix has been fixed.
- new_format.format = ur"\1\2"
+ new_format.format = u(r"\1\2")
available_formats.append(new_format)
# Now we format using these patterns instead of the default pattern,
@@ -3,6 +3,7 @@
>>> import re
>>> from re_util import fullmatch
+>>> from .util import u
>>> string = 'abcd'
>>> r1 = re.compile('abcd')
>>> r2 = re.compile('bc')
@@ -15,8 +16,8 @@
>>> m = fullmatch(r, '1234567890')
>>> m.end()
10
->>> r = re.compile(u'[+\uff0b\\d]', re.UNICODE)
->>> m = fullmatch(r, u'\uff10')
+>>> r = re.compile(u('[+\uff0b\\d]'), re.UNICODE)
+>>> m = fullmatch(r, u('\uff10'))
>>> m.end()
1
"""
@@ -1,10 +1,11 @@
"""Unicode utility functions
>>> import unicode_util
+>>> from .util import u
>>> u1 = '1' # DIGIT ONE
->>> u2 = u'a' # LATIN SMALL LETTER A
->>> u3 = u'\uFF12' # FULLWIDTH DIGIT TWO
->>> u4 = u'\u0100' # LATIN CAPITAL LETTER A WITH MACRON
+>>> u2 = u('a') # LATIN SMALL LETTER A
+>>> u3 = u('\uFF12') # FULLWIDTH DIGIT TWO
+>>> u4 = u('\u0100') # LATIN CAPITAL LETTER A WITH MACRON
>>> unicode_util.Category.get(u1)
'Nd'
>>> unicode_util.Category.get(u2)
@@ -15,7 +16,7 @@
'Lu'
>>> unicode_util.Category.get(u2) == unicode_util.Category.LOWERCASE_LETTER
True
->>> beyond_bmp = u'\U00010100' # AEGEAN WORD SEPARATOR LINE
+>>> beyond_bmp = u('\U00010100') # AEGEAN WORD SEPARATOR LINE
>>> if len(beyond_bmp) == 1: # We have a UCS4 build of Python
... unicode_util.Category.get(beyond_bmp)
... else: # UCS2 build of Python; no non-BMP chars available
@@ -45,11 +46,11 @@
>>> b4 = unicode_util.Block.get(u4)
>>> b4 == unicode_util.Block.LATIN_EXTENDED_A
True
->>> unicode_util.Block.get(u'\u0860') == unicode_util.Block.UNKNOWN
+>>> unicode_util.Block.get(u('\u0860')) == unicode_util.Block.UNKNOWN
True
->>> beyond_bmp = u'\U00013430'
+>>> beyond_bmp = u('\U00013430')
>>> if len(beyond_bmp) == 1: # We have a UCS4 build of Python
-... unicode_util.Block.get(u'\U00013430') == unicode_util.Block.UNKNOWN
+... unicode_util.Block.get(u('\U00013430')) == unicode_util.Block.UNKNOWN
... else: # UCS2 build of Python; no unknown characters available
... True
True

0 comments on commit 59f4e2f

Please sign in to comment.