Re: importing entries

will guaraldi <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
On Thu, 7 Apr 2005, Bill Mill wrote:
>
> Anybody have a better suggestion for file naming? I can't think of one.

200 characters is a _long_ filename.  I think I'd strip bad characters out 
(quotes, punctuation, ...) by converting them to _.  Then convert 
instances where there are multiple _ next to each other to just one _. 
Then, I'd split on _, and take out "stop words" like "and", "but", 
"then", "the", ...  Then join on _ again.

If nothing is left, I'd label it "untitled".  That handles entries with 
titles like "$#($8!!!" better than just naming it _.

Then I'd check to see if there's already an entry with that filename and 
do something like this:

    fn = "somefilename"
    if os.path.isfile(fn):
       index = 1
       base, ext = os.path.splitext(fn)
       while os.path.isfile("%s%d%s" % (base, index, ext)):
          index += 1

       fn = "%s%d%s" % (base, index, ext)

Or something like that--this is ultra-off-the-cuff and wholly untested and 
might cause accidental dismemberment, so use it with caution.

On the flip side, it might be interesting to give the user the option of 
using the date in the filename.

Also, in preparation of us fixing the problem we have with mtime and 
metadata, I'd toss an mtime into the entry in the metadata.  Call it 
something like "creationdate" or something like that.  Maybe toss other 
things in the metadata as well.  Can't hurt.  Maybe ask the user what they 
want in the metadata?

/will


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.