Skip to content

Commit 5040170

Browse files
committed
Add providing location for fetch
extends aboutcode-org#54 Signed-off-by: Mateusz Perc <[email protected]>
1 parent 42110e9 commit 5040170

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/fetchcode/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,16 @@ def fetch_ftp(url, location):
8888
return resp
8989

9090

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

96-
temp = tempfile.NamedTemporaryFile(delete=False)
97-
location = temp.name
98+
if location is None:
99+
temp = tempfile.NamedTemporaryFile(delete=False)
100+
location = temp.name
98101

99102
url_parts = urlparse(url)
100103
scheme = url_parts.scheme

0 commit comments

Comments
 (0)