ftplib question

John J. Lee jjl at pobox.com
Thu Jun 19 08:24:41 EDT 2003


"Avner Ben" <avner at skilldesign.com> writes:

> How do I find the year of a remote file in ftplib?
> 
> retrlines('LIST') seems to include only month day and hour.

There is code here to parse this format (actually the unix 'ls -l'
format):

http://wwwsearch.sourceforge.net/ClientCookie/src/ClientCookie-0.3.5b.tar.gz
or
http://wwwsearch.sourceforge.net/ClientCookie/src/ClientCookie-0_3_5b.zip

from ClientCookie import str2time
time.gmtime(str2time("Mar 19 17:15"))
(2003, 3, 19, 17, 15, 0, 2, 78, 0)

It lives in ClientCookie/_HTTPDate (note the 0.4.x versions can't
parse this format), which you could just strip out and use standalone
with little effort.  The function accepts all kinds of nonsense, which
may or may not be a good thing for you.


John




More information about the Python-list mailing list