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


Groups > comp.lang.python > #44918

Re: Making safe file names

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.023
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'encoding': 0.05; 'subject:file': 0.07; 'versions.': 0.07; 'bytes.': 0.09; 'currently,': 0.09; 'filenames': 0.09; 'api': 0.11; 'mostly': 0.14; "wouldn't": 0.14; 'windows': 0.15; 'caches': 0.16; 'naming': 0.16; 'those,': 0.16; 'unicode,': 0.16; 'unix,': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'artist': 0.24; 'unicode': 0.24; 'decide': 0.24; 'header:In-Reply-To:1': 0.27; 'andrew': 0.30; 'characters': 0.30; 'code': 0.31; 'adequate': 0.31; 'file': 0.32; 'run': 0.32; "i'd": 0.34; 'but': 0.35; 'there': 0.35; 'really': 0.36; '(e.g.,': 0.36; 'list': 0.37; 'easily': 0.37; 'problems': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'most': 0.60; "you're": 0.61; 'first': 0.61; 'such': 0.63; 'different': 0.65; 'forward': 0.65; 'received:74.208': 0.68; 'strategies': 0.77; 'allowable': 0.84; 'characters,': 0.84; 'conflicts': 0.84; 'received:74.208.4.194': 0.84; 'subject:Making': 0.84
Date Tue, 07 May 2013 20:14:54 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5
MIME-Version 1.0
To python-list@python.org
Subject Re: Making safe file names
References <51895D03.4000300@gmail.com>
In-Reply-To <51895D03.4000300@gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:AKr2xSFIH4SySBy7Qfo3CnCujjdHspzT1+sLR94ijvL K26tBO70eQlzZWFQtmE941PIM/BeCnaEDvjtJLrsxzEC+dlaZK rvdlFtxbkC5W008USUmKBmpe8YThSw+N8toReLYg+T9vnI5OK1 cFaM5FxkNgt39lw3yly1vEcyzzc6x7bxQFPvC7aPvVsLwqRHUW fJ+xyh6MGeyumZrE3P09QVHKEVf+u/AhPO7UbIx7sscbYfjOiR 6qRRlEXMtaTtVGrWN4/JonwBrHPdfpgMBKBjO4+aDomomDPQLl AoJQR020e+iC9DQ93OVGH7SJ3C1JxnIWDu3mQg14tDft6DwvRn sBp41oZhLhUYsk9msn7g=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1428.1367972114.3114.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367972114 news.xs4all.nl 15908 [2001:888:2000:d::a6]:41127
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44918

Show key headers only | View raw


On 05/07/2013 03:58 PM, Andrew Berg wrote:
> Currently, I keep Last.fm artist data caches to avoid unnecessary API calls and have been naming the files using the artist name. However,
> artist names can have characters that are not allowed in file names for most file systems (e.g., C/A/T has forward slashes). Are there any
> recommended strategies for naming such files while avoiding conflicts (I wouldn't want to run into problems for an artist named C-A-T or
> CAT, for example)? I'd like to make the files easily identifiable, and there really are no limits on what characters can be in an artist name.
>

So what you need first is a list of allowable characters for all your 
target OS versions.  And don't forget that the allowable characters may 
vary depending on the particular file system(s) mounted on a given OS.

You also need to decide how to handle Unicode characters, since they're 
different for different OS.  In Windows on NTFS, filenames are in 
Unicode, while on Unix, filenames are bytes.  So on one of those, you 
will be encoding/decoding if your code is to be mostly portable.

Don't forget that ls and rm may not use the same encoding you're using. 
  So you may not consider it adequate to make the names legal, but you 
may also want they easily typeable in the shell.

-- 
DaveA

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


Thread

Re: Making safe file names Dave Angel <davea@davea.name> - 2013-05-07 20:14 -0400
  Re: Making safe file names Roy Smith <roy@panix.com> - 2013-05-07 20:22 -0400

csiph-web