On May 27, 2005, at 01:39, Ronald Oussoren wrote: > On 26-mei-2005, at 16:54, Jonathan Wight wrote: > >> After adding Gideon's suggestion for CRLF ending file. My importer is >> failing on only 8 files out of 3084 files. >> >> All the failures are with Python files that try to generate the >> __version__ attribute with code instead, e.g.: >> >> __version__ = string.split('$Revision: 1.8 $')[1] >> __version__ = '$Revision: 1.6 $'[11:-2] >> >> And so on. >> >> My options are: >> >> #1 Continue to fail and not process the script any further (easiest >> solution ;-) >> #2 Just ignore the attribute in question. >> #3 Convert the attribute into a string even though it might not make >> much sense. >> #4 Execute the line and get the computed value of the attribute. >> >> I don't really want to execute the line - who the heck knows what it >> could do. Unless anyone has any better ideas I'm just going to try >> and gracefully ignore the attribute. >> > > You could try to recognize some forms of safe python code and > execute those. > I'd expect that the lines you mention above would be the majority of > computed __version__ attributes.
There's another __version__ format that seems semi-common too (well 3 instances out of 3000 or so files ;-); a tuple of two or three integers: __version__ = (1, 0, 0) There's also an __date__ that someone decided to do some slicing on as well. Right now - I'm just going to silently ignore any non-string metadata. I don't think anyone is going is to lose sleep over the lost metadata ;-) Thanks for the input though. Jon. _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig