Skip to content

Commit

Permalink
Add providing location for fetch
Browse files Browse the repository at this point in the history
extends aboutcode-org#54

Signed-off-by: Mateusz Perc <m.perc@samsung.com>
  • Loading branch information
quepop committed Jun 11, 2021
1 parent 42110e9 commit 5040170
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/fetchcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@ def fetch_ftp(url, location):
return resp


def fetch(url):
def fetch(url, location=None):
"""
Return a `Response` object built from fetching the content at the `url` URL string and store content at a temporary file.
Saving the content in a file at `location`.
If location is None, save the file in a newly created temporary directory.
"""

temp = tempfile.NamedTemporaryFile(delete=False)
location = temp.name
if location is None:
temp = tempfile.NamedTemporaryFile(delete=False)
location = temp.name

url_parts = urlparse(url)
scheme = url_parts.scheme
Expand Down

0 comments on commit 5040170

Please sign in to comment.