Mercurial > hg
comparison mercurial/posix.py @ 34131:0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Our code transformer can't rewrite string literals in docstrings, and I
don't want to make the transformer more complex.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 03 Sep 2017 14:32:11 +0900 |
parents | 8cb9e921ef8c |
children | 90b0e1639fd4 |
comparison
equal
deleted
inserted
replaced
34130:ada8a19672ab | 34131:0fa781320203 |
---|---|
50 | 50 |
51 def split(p): | 51 def split(p): |
52 '''Same as posixpath.split, but faster | 52 '''Same as posixpath.split, but faster |
53 | 53 |
54 >>> import posixpath | 54 >>> import posixpath |
55 >>> for f in ['/absolute/path/to/file', | 55 >>> for f in [b'/absolute/path/to/file', |
56 ... 'relative/path/to/file', | 56 ... b'relative/path/to/file', |
57 ... 'file_alone', | 57 ... b'file_alone', |
58 ... 'path/to/directory/', | 58 ... b'path/to/directory/', |
59 ... '/multiple/path//separators', | 59 ... b'/multiple/path//separators', |
60 ... '/file_at_root', | 60 ... b'/file_at_root', |
61 ... '///multiple_leading_separators_at_root', | 61 ... b'///multiple_leading_separators_at_root', |
62 ... '']: | 62 ... b'']: |
63 ... assert split(f) == posixpath.split(f), f | 63 ... assert split(f) == posixpath.split(f), f |
64 ''' | 64 ''' |
65 ht = p.rsplit('/', 1) | 65 ht = p.rsplit('/', 1) |
66 if len(ht) == 1: | 66 if len(ht) == 1: |
67 return '', p | 67 return '', p |
340 - escape-encode invalid characters | 340 - escape-encode invalid characters |
341 - decompose to NFD | 341 - decompose to NFD |
342 - lowercase | 342 - lowercase |
343 - omit ignored characters [200c-200f, 202a-202e, 206a-206f,feff] | 343 - omit ignored characters [200c-200f, 202a-202e, 206a-206f,feff] |
344 | 344 |
345 >>> normcase('UPPER') | 345 >>> normcase(b'UPPER') |
346 'upper' | 346 'upper' |
347 >>> normcase('Caf\xc3\xa9') | 347 >>> normcase(b'Caf\xc3\xa9') |
348 'cafe\\xcc\\x81' | 348 'cafe\\xcc\\x81' |
349 >>> normcase('\xc3\x89') | 349 >>> normcase(b'\xc3\x89') |
350 'e\\xcc\\x81' | 350 'e\\xcc\\x81' |
351 >>> normcase('\xb8\xca\xc3\xca\xbe\xc8.JPG') # issue3918 | 351 >>> normcase(b'\xb8\xca\xc3\xca\xbe\xc8.JPG') # issue3918 |
352 '%b8%ca%c3\\xca\\xbe%c8.jpg' | 352 '%b8%ca%c3\\xca\\xbe%c8.jpg' |
353 ''' | 353 ''' |
354 | 354 |
355 try: | 355 try: |
356 return encoding.asciilower(path) # exception for non-ASCII | 356 return encoding.asciilower(path) # exception for non-ASCII |