[Python-Dev] Why doesn't the uu module give you the filename?
Sun, 27 Apr 2003 11:49:02 -0400
While it's simple enough to get the uu module to uudecode a string
(using StringIO), it's impossible to get it to handle you the filename
the uuencoded thing specifies.
begin 644 a.ii.gz
Their is no way to get the decode function to tell you the thing is
Of course, it uses this filename itself in creating an output file if
you don't specify one. It just won't tell *you* what the filename is.
I could just give it no output file, and let it create it, then
determine the name of the file it created, but this seems like a very
Besides, I am decoding from/to a string, in memory. I don't want to
start have it write things to the disk for no reason.
The context of all of this is that I have a program that is converting
text that possibly contains uuencoded attachments into a bunch of SQL
statements to insert into a database (It's converting a GNATS bug
database to a Bugzilla one. It's a rewrite of an incredibly ugly, slow,
barely functional perl script that spews errors at random and leaks
memory for no reason :P).
I had to cut/paste the decode function from the uu module into a new
module and make it return the filename, just so that i could get access
This seems a bit silly.
The decode function has no return value right now, so giving it one
shouldn't break existing applications (since none of them should be
expecting it to return anything).
I believe it should return the filename specified in the begin line.
As an added bonus, it would be even nicer if it also returned the start
and end position of the decoded portion inside the input text. that
way if one wants to replace the entire uuencoded text with something
like, say, "See bug attachments for <filename>", you can do it easily.
As i said, i've got a version of uu.decode that does all of this, i'll
happily submit it as a patch if people agree i'm right.