Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; ';-)': 0.03; 'debugging': 0.07; 'exists.': 0.07; 'paths': 0.07; 'see.': 0.07; 'string': 0.09; '22,': 0.09; 'app,': 0.09; 'filenames': 0.09; 'oh,': 0.09; 'rows,': 0.09; 'slow.': 0.09; 'cc:addr:python-list': 0.11; 'django': 0.11; 'jan': 0.12; 'stored': 0.12; 'itself.': 0.14; '*why*': 0.16; 'considers': 0.16; 'correlation': 0.16; 'efficiency.': 0.16; 'one)': 0.16; 'parts.': 0.16; 'query,': 0.16; 'recorded': 0.16; 'roy': 0.16; 'subject:Case': 0.16; 'subject:exists': 0.16; 'subject:insensitive': 0.16; 'apps': 0.16; 'folks': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'differ': 0.19; '(the': 0.22; 'coding': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'example.': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'script': 0.25; 'compare': 0.26; 'query': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'characters': 0.30; 'matching': 0.30; 'originally': 0.30; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'program,': 0.31; 'serve': 0.31; '(perhaps': 0.31; 'easy,': 0.31; 'larry': 0.31; 'file': 0.32; 'handled': 0.32; 'run': 0.32; 'cases': 0.33; 'guess': 0.33; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'crazy': 0.36; 'words,': 0.36; 'done': 0.36; 'doing': 0.36; 'entry': 0.36; "i'll": 0.36; 'too': 0.37; 'operating': 0.37; 'list': 0.37; 'problems': 0.38; 'others.': 0.38; 'files': 0.38; 'issue': 0.38; 'pm,': 0.38; 'users': 0.40; 'how': 0.40; 'serving': 0.60; 'full': 0.61; 'simple': 0.61; "you're": 0.61; 'back': 0.62; 'name': 0.63; 'high': 0.63; 'today': 0.64; 'more': 0.64; 'different': 0.65; 'revealed': 0.68; 'smith': 0.68; 'user,': 0.69; 'receive': 0.70; 'records': 0.73; 'article': 0.77; 'browser.': 0.78; 'informed': 0.78; 'working,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=jnzwfXMs5UCgZiIVP6XrdneTrm1pLVGBO2CmoGe5C4s=; b=Tv3VK4KRB7xAJI0AQjgtGMWSLfeeexk0HumAm5HkCPpLF5A1DJ/nsBsceOdlSDwGt+ 4Ar5cMfkSLcxprmY198JpQkMvN4+v0c3JBZSKLJMaOWFAzUUColnp9T/GVwr7N9z4CEc s7Y6nR/OQWSkvSIsdgnmzEFQhGSGz3LBCGz1PSmMLPPyqDLu2Qi7SETR8Gx7szXhg19g mUnhaofvEszMeyr/MlRDIVAcn7OOXBgnMn01+TZOVmGFEEyBBEs5/82W53A8QplN5hs5 WtOmkD9S3pK9sRpD9yVCxE0EiMPwVVdzPwu2b4wbNYTn2m3Dhd7F7ndYJ9PuOT4EGiGd 737Q== MIME-Version: 1.0 X-Received: by 10.220.133.148 with SMTP id f20mr3330496vct.2.1390451094319; Wed, 22 Jan 2014 20:24:54 -0800 (PST) In-Reply-To: References: Date: Wed, 22 Jan 2014 21:24:54 -0700 Subject: Re: Case insensitive exists()? From: Larry Martell To: Roy Smith Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390451096 news.xs4all.nl 2943 [2001:888:2000:d::a6]:56598 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64564 On Wed, Jan 22, 2014 at 6:27 PM, Roy Smith wrote: > In article , > Larry Martell 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.