@@ -87,7 +87,7 @@ def hexvalue(value):
87
87
class UnicodeVersion (object ):
88
88
89
89
def __init__ (self , version ):
90
- result = re .match ('^(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)$' , version )
90
+ result = re .match (r '^(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)$' , version )
91
91
if result :
92
92
self .major = int (result .group ('major' ))
93
93
self .minor = int (result .group ('minor' ))
@@ -172,7 +172,7 @@ class UnicodeData(object):
172
172
self .ucd_props = collections .defaultdict (list )
173
173
for line in f_pl .splitlines ():
174
174
result = re .match (
175
- '^(?P<start>[0-9A-F]{4,6})(|\.\.(?P<end>[0-9A-F]{4,6}))\s*;\s*(?P<prop>\S+)\s*(|\#.*)$' ,
175
+ r '^(?P<start>[0-9A-F]{4,6})(|\.\.(?P<end>[0-9A-F]{4,6}))\s*;\s*(?P<prop>\S+)\s*(|\#.*)$' ,
176
176
line )
177
177
if result :
178
178
if result .group ('end' ):
@@ -187,7 +187,7 @@ class UnicodeData(object):
187
187
f_dcp = self ._ucdfile ('DerivedCoreProperties.txt' )
188
188
for line in f_dcp .splitlines ():
189
189
result = re .match (
190
- '^(?P<start>[0-9A-F]{4,6})(|\.\.(?P<end>[0-9A-F]{4,6}))\s*;\s*(?P<prop>\S+)\s*(|\#.*)$' ,
190
+ r '^(?P<start>[0-9A-F]{4,6})(|\.\.(?P<end>[0-9A-F]{4,6}))\s*;\s*(?P<prop>\S+)\s*(|\#.*)$' ,
191
191
line )
192
192
if result :
193
193
if result .group ('end' ):
@@ -203,7 +203,7 @@ class UnicodeData(object):
203
203
f_b = self ._ucdfile ('Blocks.txt' )
204
204
for line in f_b .splitlines ():
205
205
result = re .match (
206
- '^(?P<start>[0-9A-F]{4,6})\.\.(?P<end>[0-9A-F]{4,6})\s*;\s*(?P<block>.*)\s*$' ,
206
+ r '^(?P<start>[0-9A-F]{4,6})\.\.(?P<end>[0-9A-F]{4,6})\s*;\s*(?P<block>.*)\s*$' ,
207
207
line )
208
208
if result :
209
209
for i in hexrange (result .group ('start' ), result .group ('end' )):
@@ -216,7 +216,7 @@ class UnicodeData(object):
216
216
f_cf = self ._ucdfile ('CaseFolding.txt' )
217
217
for line in f_cf .splitlines ():
218
218
result = re .match (
219
- '^(?P<cp>[0-9A-F]{4,6})\s*;\s*(?P<type>\S+)\s*;\s*(?P<subst>[0-9A-F\s]+)\s*' ,
219
+ r '^(?P<cp>[0-9A-F]{4,6})\s*;\s*(?P<type>\S+)\s*;\s*(?P<subst>[0-9A-F\s]+)\s*' ,
220
220
line )
221
221
if result :
222
222
if result .group ('type' ) in ('C' , 'F' ):
@@ -229,7 +229,7 @@ class UnicodeData(object):
229
229
f_hst = self ._ucdfile ('HangulSyllableType.txt' )
230
230
for line in f_hst .splitlines ():
231
231
result = re .match (
232
- '^(?P<start>[0-9A-F]{4,6})\.\.(?P<end>[0-9A-F]{4,6})\s*;\s*(?P<type>\S+)\s*(|\#.*)$' ,
232
+ r '^(?P<start>[0-9A-F]{4,6})\.\.(?P<end>[0-9A-F]{4,6})\s*;\s*(?P<type>\S+)\s*(|\#.*)$' ,
233
233
line )
234
234
if result :
235
235
for i in hexrange (result .group ('start' ), result .group ('end' )):
@@ -240,7 +240,7 @@ class UnicodeData(object):
240
240
self .ucd_as = {}
241
241
f_as = self ._ucdfile ('ArabicShaping.txt' )
242
242
for line in f_as .splitlines ():
243
- result = re .match ('^(?P<cp>[0-9A-F]{4,6})\s*;\s*.*?\s*;\s*(?P<jt>\S+)\s*;' , line )
243
+ result = re .match (r '^(?P<cp>[0-9A-F]{4,6})\s*;\s*.*?\s*;\s*(?P<jt>\S+)\s*;' , line )
244
244
if result :
245
245
self .ucd_as [int (result .group ('cp' ), 16 )] = result .group ('jt' )
246
246
@@ -250,7 +250,7 @@ class UnicodeData(object):
250
250
f_s = self ._ucdfile ('Scripts.txt' )
251
251
for line in f_s .splitlines ():
252
252
result = re .match (
253
- '^(?P<start>[0-9A-F]{4,6})(|\.\.(?P<end>[0-9A-F]{4,6}))\s*;\s*(?P<script>\S+)\s*(|\#.*)$' ,
253
+ r '^(?P<start>[0-9A-F]{4,6})(|\.\.(?P<end>[0-9A-F]{4,6}))\s*;\s*(?P<script>\S+)\s*(|\#.*)$' ,
254
254
line )
255
255
if result :
256
256
if not result .group ('script' ) in self .ucd_s :
@@ -268,7 +268,7 @@ class UnicodeData(object):
268
268
f_idnamt = self ._ucdfile ('IdnaMappingTable.txt' , urlbase = UTS46_URL )
269
269
for line in f_idnamt .splitlines ():
270
270
result = re .match (
271
- '^(?P<start>[0-9A-F]{4,6})(|\.\.(?P<end>[0-9A-F]{4,6}))\s*;\s*(?P<fields>[^#]+)' ,
271
+ r '^(?P<start>[0-9A-F]{4,6})(|\.\.(?P<end>[0-9A-F]{4,6}))\s*;\s*(?P<fields>[^#]+)' ,
272
272
line )
273
273
if result :
274
274
fields = [x .strip () for x in result .group ('fields' ).split (';' )]
@@ -515,7 +515,7 @@ def idna_libdata(ucdata):
515
515
#
516
516
yield 'scripts = {'
517
517
for script in SCRIPT_WHITELIST :
518
- prefix = ' \' {0 }\' : ' .format (script )
518
+ prefix = ' \' {}\' : ' .format (script )
519
519
for line in optimised_list (ucdata .ucd_s [script ]):
520
520
yield prefix + line
521
521
prefix = ''
@@ -527,7 +527,7 @@ def idna_libdata(ucdata):
527
527
yield 'joining_types = {'
528
528
for cp in ucdata .codepoints ():
529
529
if cp .joining_type :
530
- yield ' 0x{0 :x}: {1 },' .format (cp .value , ord (cp .joining_type ))
530
+ yield ' 0x{:x}: {},' .format (cp .value , ord (cp .joining_type ))
531
531
yield '}'
532
532
533
533
#
@@ -543,7 +543,7 @@ def idna_libdata(ucdata):
543
543
classes [status ] = set ()
544
544
classes [status ].add (cp .value )
545
545
for status in ['PVALID' , 'CONTEXTJ' , 'CONTEXTO' ]:
546
- prefix = ' \' {0 }\' : ' .format (status )
546
+ prefix = ' \' {}\' : ' .format (status )
547
547
for line in optimised_list (classes [status ]):
548
548
yield prefix + line
549
549
prefix = ''
@@ -567,9 +567,9 @@ def uts46_ranges(ucdata):
567
567
last = (status , mapping )
568
568
569
569
if mapping is not None :
570
- yield '(0x{0 :X}, \' {1 }\' , \' {2 }\' )' .format (cp .value , status , mapping )
570
+ yield '(0x{:X}, \' {}\' , \' {}\' )' .format (cp .value , status , mapping )
571
571
else :
572
- yield '(0x{0 :X}, \' {1 }\' )' .format (cp .value , status )
572
+ yield '(0x{:X}, \' {}\' )' .format (cp .value , status )
573
573
574
574
def uts46_libdata (ucdata ):
575
575
@@ -585,14 +585,14 @@ def uts46_libdata(ucdata):
585
585
if idx % UTS46_SEGMENT_SIZE == 0 :
586
586
if idx != 0 :
587
587
yield ' ]\n '
588
- yield 'def _seg_{0 }():\n return [' .format (idx // UTS46_SEGMENT_SIZE )
589
- yield ' {0 },' .format (row )
588
+ yield 'def _seg_{}():\n return [' .format (idx // UTS46_SEGMENT_SIZE )
589
+ yield ' {},' .format (row )
590
590
yield ' ]\n '
591
591
592
592
yield 'uts46data = tuple('
593
593
yield ' _seg_0()'
594
594
for i in range (1 , idx // UTS46_SEGMENT_SIZE + 1 ):
595
- yield ' + _seg_{0 }()' .format (i )
595
+ yield ' + _seg_{}()' .format (i )
596
596
yield ')'
597
597
598
598
def make_libdata (args , ucdata ):
@@ -655,7 +655,7 @@ def main():
655
655
elif args .action == 'make-libdata' :
656
656
make_libdata (args , ucdata )
657
657
else :
658
- result = re .match ('^(?i)(U\+|)(?P<cp>[0-9A-F]{4,6})$' , args .action )
658
+ result = re .match (r '^(?i)(U\+|)(?P<cp>[0-9A-F]{4,6})$' , args .action )
659
659
if result :
660
660
codepoint = int (result .group ('cp' ), 16 )
661
661
diagnose_codepoint (codepoint , args , ucdata )
0 commit comments