def exists(self, path):
<EOL>if sys.version_info[<NUM_LIT:0>] >= <NUM_LIT:3>:<EOL><INDENT>from urllib.request import urlopen<EOL>from urllib.error import URLError<EOL><DEDENT>else:<EOL><INDENT>from urllib2 import urlopen<EOL>from urllib2 import URLError<EOL><DEDENT>if os.path.exists(path):<EOL><INDENT>return True<EOL><DEDENT>upath = self.abspath(path)<EOL>if os.path.exists(upath):<EOL><INDENT>return True<EOL><DEDENT>if self._isurl(path):<EOL><INDENT>try:<EOL><INDENT>netfile = urlopen(path)<EOL>netfile.close()<EOL>del(netfile)<EOL>return True<EOL><DEDENT>except URLError:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return False<EOL>
Test if path exists.

Test if `path` exists as (and in this order):

- a local file.
- a remote URL that has been downloaded and stored locally in the
  `DataSource` directory.
- a remote URL that has not been downloaded, but is valid and
  accessible.

Parameters
----------
path : str
    Can be a local file or a remote URL.

Returns
-------
out : bool
    True if `path` exists.

Notes
-----
When `path` is an URL, `exists` will return True if it's either
stored locally in the `DataSource` directory, or is a valid remote
URL.  `DataSource` does not discriminate between the two, the file
is accessible if it exists in either location.