On 05/10/2010 12:04, Steven D'Aprano wrote: > On Tue, 5 Oct 2010 07:21:15 pm Chris Withers wrote: >> On 25/09/2010 04:25, Steven D'Aprano wrote: >>> 1. Return the case of a filename in some canonical form which >>> depends on the file system? >>> 2. Return the case of a filename as it is actually stored on disk? >> >> How do 1 and 2 differ? > > Case #1 imposes a particular canonical form, regardless of what is > actually stored on disk. It is similar to normpath, except that we > could have different canonical forms depending on what the file system > was. normpath merely generalises from the operating system, and never > looks at the file system. Ah, okay, yeah, that's actually an anti-goal for me ;-) > Case #2 says to actually look at the file and see what the file system > considers it's name to be. Consider a NTFS file system. By default it > is case-preserving and case-insensitive, although that can be changed. > (Just because a file system is NTFS doesn't mean that will be > case-insensitive. NTFS can also run in a POSIX mode which is > case-sensitive. But I digress.) Yeah, this is definitely where I think the missing use case lies... >> FWIW, the use case that setuptools has (and >> for which it currently incorrectly uses normpath) is number 2. >> >>> 4. Return the case of a filename in some arbitrarily-chosen >>> canonical form which does not depend on the file system? >> >> This is what normpath does, but only if you're on Windows ;-) > > Not quite. macpath.normcase() also lowercases the path. So does the > module for OS/2. Interesting, since I develop on MacOS, Linux and Windows and only experienced the problem caused by setuptools normcase'ing distribution names on Windows. The MacOS case also isn't in the docs. > In any case, Windows is not a file system. It is quite possible to have > virtually any combination of case-destroying, case-preserving, > -sensitive and -insensitive file systems on the one Windows system. Say, > a FAT12 floppy, an NTFS partition, and an ext2 USB stick. Windows > doesn't ship with native support for ext2, but that doesn't mean it > can't be installed with third party drivers. yes, exactly! > normpath pays no attention to any of this, and just lowercases the path. > At least that's cheap, and consistent, even if it solves the wrong > problem :) ...and creates a few more along the way ;-) Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4