[Patches] [ python-Patches-525945 ] urllib: Defering open call for file urls
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 05 Mar 2002 06:21:28 -0800
Patches item #525945, was opened at 2002-03-05 14:59
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=525945&group_id=5470
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib: Defering open call for file urls
Initial Comment:
This patch changes the handling of local files in
urllib.urlopen() and urllib2.urlopen(). Opening the
file is deferred until the first time read(), readline
(), readlines() or fileno() is called.
This makes it possible to retrieve the header
information for all URLs via urlopen in a uniform way,
without actually having to open the file.
----------------------------------------------------------------------
>Comment By: Walter Dörwald (doerwalter)
Date: 2002-03-05 15:21
Message:
Logged In: YES
user_id=89016
I'm currently writing a make in Python. This make should be
able to handle not only local files, but remote files
(http, ftp, etc.). One project might have several thousand
targets, and some of them are remote. I want to be able to
handle both types in a uniform way, i.e. via
urllib/urllib2. This means, that I call urllib2.urlopen()
to get the header information about the last modification
date, but I don't want to open the file right away. Only
when the data is required (because the source resource is
newer than the target) should the file be read.
And this might open the door to making streams that are
returned from urlopen() writable (simply by using open
(..., "wb") instead of open(..., "rb") when the first write
is called.
Another possibility might be using urllib.urlretrieve(), but
the API is horrible (one global cleanup function) and not
supported by urllib2.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-03-05 15:09
Message:
Logged In: YES
user_id=6380
I don't understand. Can you explain why you care about
this?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=525945&group_id=5470