Skip to content

Commit

Permalink
Allow open() and tle() to take plain paths
Browse files Browse the repository at this point in the history
Fixes #137.
  • Loading branch information
brandon-rhodes committed Jul 25, 2018
1 parent f249601 commit d5b70da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions skyfield/iokit.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,20 @@ def open(self, url, mode='rb', reload=False, filename=None):
this ``my_loader.open()`` method does not attempt to parse or
interpret the file; it simply returns an open file object.
If the ``reload`` parameter is true, then any existing file will
be removed before the download starts.
The ``url`` can be either an external URL, or else the path to a
file on the current filesystem. A relative path will be assumed
to be relative to the base directory of this loader object.
If a URL was provided and the ``reload`` parameter is true, then
any existing file will be removed before the download starts.
The ``filename`` parameter lets you specify an alternative local
filename instead of having the filename extracted from the final
component of the URL.
"""
if '://' not in url:
return open(url, mode)
if filename is None:
filename = urlparse(url).path.split('/')[-1]
path = self.path_to(filename)
Expand Down

0 comments on commit d5b70da

Please sign in to comment.