equal
deleted
inserted
replaced
206 ''' |
206 ''' |
207 Normalize a filename for OS X-compatible comparison: |
207 Normalize a filename for OS X-compatible comparison: |
208 - escape-encode invalid characters |
208 - escape-encode invalid characters |
209 - decompose to NFD |
209 - decompose to NFD |
210 - lowercase |
210 - lowercase |
|
211 - omit ignored characters [200c-200f, 202a-202e, 206a-206f,feff] |
211 |
212 |
212 >>> normcase('UPPER') |
213 >>> normcase('UPPER') |
213 'upper' |
214 'upper' |
214 >>> normcase('Caf\xc3\xa9') |
215 >>> normcase('Caf\xc3\xa9') |
215 'cafe\\xcc\\x81' |
216 'cafe\\xcc\\x81' |
263 # any remaining partial characters |
264 # any remaining partial characters |
264 s += ''.join(["%%%02X" % ord(x) for x in g]) |
265 s += ''.join(["%%%02X" % ord(x) for x in g]) |
265 u = s.decode('utf-8') |
266 u = s.decode('utf-8') |
266 |
267 |
267 # Decompose then lowercase (HFS+ technote specifies lower) |
268 # Decompose then lowercase (HFS+ technote specifies lower) |
268 return unicodedata.normalize('NFD', u).lower().encode('utf-8') |
269 enc = unicodedata.normalize('NFD', u).lower().encode('utf-8') |
|
270 # drop HFS+ ignored characters |
|
271 return encoding.hfsignoreclean(enc) |
269 |
272 |
270 if sys.platform == 'cygwin': |
273 if sys.platform == 'cygwin': |
271 # workaround for cygwin, in which mount point part of path is |
274 # workaround for cygwin, in which mount point part of path is |
272 # treated as case sensitive, even though underlying NTFS is case |
275 # treated as case sensitive, even though underlying NTFS is case |
273 # insensitive. |
276 # insensitive. |