howlongwillitlast14 / appdailysales

Automatically exported from code.google.com/p/appdailysales
0 stars 0 forks source link

Add option to rename file #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
How about auto-naming the file with the date or something? Apple's name is
a tad obscure ;)...

Original issue reported on code.google.com by ki...@thecave.com on 11 Dec 2008 at 2:29

GoogleCodeExporter commented 8 years ago
+1 on this, I'd really really like that feature - it'll save me having to 
coordinate
this script running and a bash script running after this script finishes!

Seems like it would be a simple matter of adding a line like filename = date
somewhere between 

            if options.verbose == True:
                print 'saving download file:', filename

and

            downloadFile = open(filename, 'w')

Can any python gurus fix my syntax?

Original comment by admiral....@gmail.com on 25 Mar 2010 at 7:21

GoogleCodeExporter commented 8 years ago
This patch adds a -f (or --format) option which will rename the files as 
they're downloaded.  The format is specified as per strftime (see man page), 
e.g. "%Y-%m-%d-foo.txt" would give you "2010-09-13-foo.txt".

(There's a couple other small changes in the patch that I didn't weed out -- 
error reporting if you get the password wrong, and outputting a temp HTML file 
if verbose is on, etc.)

Original comment by danieldickison@gmail.com on 14 Sep 2010 at 2:35

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the patch!  Nice enhancement.  I will add it tomorrow (September 16).

Original comment by kirbyt.w...@gmail.com on 16 Sep 2010 at 11:00

GoogleCodeExporter commented 8 years ago
@danieldickison Thanks again for the patch. It has been applied and committed 
to svn. I also left in the other enhancements. I especially like the temp.html 
output. It's helpful when an error occurs with the screen scraping.

Original comment by kirbyt.w...@gmail.com on 17 Sep 2010 at 12:33

GoogleCodeExporter commented 8 years ago
@kirbyt Minor point with r57: You don't have to call f.close() when using the 
'with' syntax, as that is done automagically when exiting the 'with' scope.  
It's pretty sweet. http://docs.python.org/tutorial/inputoutput.html

Original comment by danieldickison@gmail.com on 21 Sep 2010 at 10:58