Mercurial > hg > config
annotate python/open.py @ 767:35f8751c0930
it is very annoying to have ones overrides overridden; see also http://stackoverflow.com/questions/25381304/why-type-cd-on-mac-os-states-that-cd-is-a-function
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Thu, 28 Jan 2016 14:02:17 -0800 |
parents | 2025368488ee |
children |
rev | line source |
---|---|
398 | 1 def load(resource): |
2 """ | |
3 open a file or URL for reading. If the passed resource string is not a URL, | |
4 or begins with 'file://', return a ``file``. Otherwise, return the | |
5 result of urllib2.urlopen() | |
6 """ | |
7 | |
8 # handle file URLs separately due to python stdlib limitations | |
9 if resource.startswith('file://'): | |
10 resource = resource[len('file://'):] | |
11 | |
12 if not is_url(resource): | |
13 # if no scheme is given, it is a file path | |
14 return file(resource) | |
15 | |
16 return urllib2.urlopen(resource) |