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


Groups > comp.lang.python > #44909

Re: Making safe file names

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <fabiosantosart@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'argument': 0.05; 'cpython': 0.05; 'subject:file': 0.07; 'currently,': 0.09; 'suggestions:': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; 'suggest': 0.14; "wouldn't": 0.14; 'windows': 0.15; '"/"': 0.16; 'caches': 0.16; 'character.': 0.16; 'naming': 0.16; 'simple.': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'artist': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'andrew': 0.30; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'allows': 0.31; 'file': 0.32; 'run': 0.32; 'url:python': 0.33; "i'd": 0.34; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; '(e.g.,': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'easily': 0.37; 'problems': 0.38; 'url:library': 0.38; 'files': 0.38; 'pm,': 0.38; 'url:mail': 0.40; 'how': 0.40; 'most': 0.60; 'such': 0.63; 'more': 0.64; 'forward': 0.65; 'to:addr:gmail.com': 0.65; 'strategies': 0.77; '3.3.1': 0.84; '9.1': 0.84; 'conflicts': 0.84; 'freebsd': 0.84; 'subject:Making': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding; bh=ICowjYSFuG/2PsPsswzhfn9gC6dLaY/Efke6Y+63hxI=; b=wadFd+r22lvu79H3jKry8SDi/gDvioSNLAbFzTw/O8ytJ75BfBeShZFC4V+cmuUPbR HPLOZJMmu/XptoMbU3MFAx/f+uyMZxYOCokK/KVU8K7D0REE8ehfHcJBBizq8OWR8uQx uwEuQBMGTJRZJFTb5km+aPAP6n7p6b4uzg6Z7P9UuSoHUiZBNwTEf/DWig6VIfwCu3Em aW5j9ifAE0WSJB0XbL3yF5vuefiLGSGxtDZPIe1eTpOVl+KQ92E4/a0jyWVz/0lInbrS 1kGO5BqsuZSxJvEzcnzaqyq4tvTYazmb7/YvT+dwlBKapW8KEeHXFxqkfVO36bZkH8Uw jCZA==
MIME-Version 1.0
X-Received by 10.229.180.66 with SMTP id bt2mr1136388qcb.125.1367965120334; Tue, 07 May 2013 15:18:40 -0700 (PDT)
In-Reply-To <51895D03.4000300@gmail.com>
References <51895D03.4000300@gmail.com>
Date Tue, 7 May 2013 23:18:40 +0100
Subject Re: Making safe file names
From Fábio Santos <fabiosantosart@gmail.com>
To Andrew Berg <bahamutzero8825@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc "comp.lang.python" <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 <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.1422.1367965130.3114.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367965130 news.xs4all.nl 15955 [2001:888:2000:d::a6]:35117
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44909

Show key headers only | View raw


I suggest Base64. b64encode
(http://docs.python.org/2/library/base64.html#base64.b64encode) and
b64decode take an argument which allows you to eliminate the pesky "/"
character. It's reversible and simple.

More suggestions: how about a hash? Or just use IDs from the database?

On Tue, May 7, 2013 at 8:58 PM, Andrew Berg <bahamutzero8825@gmail.com> 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.
> --
> CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
> --
> http://mail.python.org/mailman/listinfo/python-list



--
Fábio Santos

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


Thread

Re: Making safe file names Fábio Santos <fabiosantosart@gmail.com> - 2013-05-07 23:18 +0100

csiph-web