Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64564

Re: Case insensitive exists()?

References <mailman.5853.1390438708.18130.python-list@python.org> <roy-7A7FAE.20082622012014@news.panix.com> <mailman.5855.1390439920.18130.python-list@python.org> <roy-1771A1.20270322012014@news.panix.com>
Date 2014-01-22 21:24 -0700
Subject Re: Case insensitive exists()?
From Larry Martell <larry.martell@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5867.1390451096.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Jan 22, 2014 at 6:27 PM, Roy Smith <roy@panix.com> wrote:
> In article <mailman.5855.1390439920.18130.python-list@python.org>,
>  Larry Martell <larry.martell@gmail.com> wrote:
>
>> The issue is that I run a database query and get back rows, each with
>> a file path (each in a different dir). And I have to check to see if
>> that file exists. Each is a separate search with no correlation to the
>> others. I have the full path, so I guess I'll have to do dir name on
>> it, then a listdir then compare each item with .lower with my string
>> .lower. It's just that the dirs have 100's and 100's of files so I'm
>> really worried about efficiency.
>
> Oh, my, this is a much more complicated problem than you originally
> described.

I try not to bother folks with simple problems ;-)

> Is the whole path case-insensitive, or just the last component?  In
> other words, if the search string is "/foo/bar/my_file_name", do all of
> these paths match?
>
> /FOO/BAR/MY_FILE_NAME
> /foo/bar/my_file_name
> /FoO/bAr/My_FiLe_NaMe

Just the file name (the basename).

> Can you give some more background as to *why* you're doing this?
> Usually, if a system considers filenames to be case-insensitive, that's
> something that's handled by the operating system itself.

I can't say why it's happening. This is a big complicated system with
lots of parts. There's some program that ftp's image files from an
electron microscope and stores them on the file system with crazy
names like:

2O_TOPO_1_2O_2UM_FOV_M1_FX-2_FY4_DX0_DY0_DZ0_SDX10_SDY14_SDZ0_RR1_TR1_Ver1.jpg

And something (perhaps the same program, perhaps a different one)
records this is a database. In some cases the name recorded in the db
has different cases in some characters then how it was stored in the
db, e.g.:

2O_TOPO_1_2O_2UM_Fov_M1_FX-2_FY4_DX0_DY0_DZ0_SDX10_SDY14_SDZ0_RR1_TR1_Ver1.jpg

These only differ in "FOV" vs. "Fov" but that is just one example.

I am writing something that is part of a django app, that based on
some web entry from the user, I run a query, get back a list of files
and have to go receive them and serve them up back to the browser. My
script is all done and seem to be working, then today I was informed
it was not serving up all the images. Debugging revealed that it was
this case issue - I was matching with exists(). As I've said, coding a
solution is easy, but I fear it will be too slow. Speed is important
in web apps - users have high expectations. Guess I'll just have to
try it and see.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 17:58 -0700
  Re: Case insensitive exists()? Roy Smith <roy@panix.com> - 2014-01-22 20:08 -0500
    Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 18:18 -0700
      Re: Case insensitive exists()? Roy Smith <roy@panix.com> - 2014-01-22 20:27 -0500
        Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 21:24 -0700
        Re: Case insensitive exists()? Chris Angelico <rosuav@gmail.com> - 2014-01-23 15:29 +1100
        Re: Case insensitive exists()? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-01-23 15:43 +0000
        Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-23 12:02 -0700
      Re: Case insensitive exists()? Dan Sommers <dan@tombstonezero.net> - 2014-01-23 07:51 +0000
  Re: Case insensitive exists()? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-23 12:06 +0000
  Re: Case insensitive exists()? Grant Edwards <invalid@invalid.invalid> - 2014-01-23 14:58 +0000

csiph-web