pyfilenametime plugin

chombee <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <1187708199.32730.3.camel@marley-20>
I started using this plugin and realised that it wasn't working. It
wasn't overriding the mtime for all (any?) of the stories that it should
have been.

So I had a look at the code and found that this re:

DAYMATCH =
re.compile('([0-9]{4})-([0-1][0-9])-([0-3][0-9])-([0-2][0-9])-([0-5][0-9]).[\w]+$')

is suspect. I don't think in regular expressions and haven't looked at
the Python docs to check what it means, but the .[\w]+$ at the end looks
unnecessary to me, and some quick tests seemed to confirm this. The re
doesn't match filenames that it should, but if you remove that weird bit
from the end it works:

Python 2.5.1 (r251:54863, May  2 2007, 16:56:35) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> datematch =
re.compile('([0-9]{4})-([0-1][0-9])-([0-3][0-9])-([0-2][0-9])-([0-5][0-9]).[\w]+$')
>>> match = datematch.search("2007-08-20-00-00-mystory.txt")
>>> str(match)
'None'
>>> datematch =
re.compile('([0-9]{4})-([0-1][0-9])-([0-3][0-9])-([0-2][0-9])-([0-5][0-9])')
>>> match = datematch.search("2007-08-20-00-00-mystory.txt")
>>> str(match)
'<_sre.SRE_Match object at 0xb78f91a0>'
>>> 

So, I don't know what .[\w]+$ is but it looks like it ought not to be
there. I have the modified plugin running on my blog now, and it seems
to work correctly for all the right stories.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
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.