[Python-ideas] PEP 428 - object-oriented filesystem paths
Joao S. O. Bueno
jsbueno at python.org.br
Mon Oct 8 17:13:55 CEST 2012
On 8 October 2012 11:28, Oleg Broytman <phd at phdru.name> wrote:
> On Mon, Oct 08, 2012 at 03:59:18PM +0200, Ronald Oussoren <ronaldoussoren at mac.com> wrote:
>> On 8 Oct, 2012, at 13:07, Oleg Broytman <phd at phdru.name> wrote:
>> > On Mon, Oct 08, 2012 at 12:00:22PM +0200, Ronald Oussoren <ronaldoussoren at mac.com> wrote:
>> >> Or CIFS filesystems mounted on a Linux? Case-sensitivity is a file-system property, not a operating system one.
>> > But there is no API to ask what type of filesystem a path belongs to.
>> > So guessing by OS name is the only heuristic we can do.
>> I guess so, as neither statvs, statvfs, nor pathconf seem to be able to tell if a filesystem is case insensitive.
>> The alternative would be to have a list of case insentive filesystems and use that that when comparing impure path objects. That would be fairly expensive though, as you'd have to check for every element of the path if that element is on a case insensitive filesystem.
> If a filesystem mounted to w32 is exported from a server by CIFS/SMB
> protocol -- is it case sensitive? What if said server is Linux? What if
> said filesystem was actually imported to Linux from a Novel server by
> NetWare Core Protocol. It's not a fictional situation -- I do it at
> oper.med.ru; the server is Linux that mounts two CIFS and NCP filesystem
> and reexport them via Samba.
Actually, after just thinking of a few corner cases, (and in this case
seen some real world scenarios) it is easy to infer that it is impossible
to estabilish for certain that a filesystem, worse, that a given
directory, is case-sensitive or not.
So, regardless of general passive assumptions, I think Python should include a
way to actively verify the filesystem case sensitivity. Something along
"assert_case_sensitiveness(<path>)" that would check for a filename
in the given path, and try to retrieve it inverting some capitalization.
If a suitable filename were not found in the given directory, it could
raise an error - or try to make an active test by writtng there (this behavior
should be controled by keyword parameters).
So, whenever one needs to know about case sensitiveness, there would
be one obvious way in place to know for shure, even at the cost of
some extra system resources.
> Oleg Broytman http://phdru.name/ phd at phdru.name
> Programmers don't die, they just GOSUB without RETURN.
Hmmm...maybe that applies for programmers who not kept up with the
times only? I'd rather raise StopVitalFunctions when my time comes.
More information about the Python-ideas