29
29
class VCSResponse :
30
30
"""
31
31
Represent the response from fetching a VCS URL with:
32
- - `dest_dir`: destination of directory
33
- - `vcs_type`: VCS Type of URL (git,bzr,hg,svn)
34
- - `domain` : Source of git VCS (GitHub, Gitlab, Bitbucket)
32
+ - `dest_dir`: destination of directory
33
+ - `vcs_type`: VCS Type of URL (git,bzr,hg,svn)
34
+ - `domain` : Source of git VCS (GitHub, Gitlab, Bitbucket)
35
35
"""
36
36
37
37
def __init__ (self , dest_dir , vcs_type , domain ):
@@ -40,16 +40,17 @@ def __init__(self, dest_dir, vcs_type, domain):
40
40
self .domain = domain
41
41
42
42
43
- def fetch_via_vcs (url ):
43
+ def fetch_via_vcs (url , location = None ):
44
44
"""
45
45
Take `url` as input and store the content of it at location specified at `location` string
46
- Return a VCSResponse object
46
+ Return a VCSResponse object
47
47
"""
48
48
parsed_url = urlparse (url )
49
49
scheme = parsed_url .scheme
50
50
domain = parsed_url .netloc
51
- temp = tempfile .mkdtemp ()
52
- os .rmdir (temp )
51
+ if location is None :
52
+ location = tempfile .mkdtemp ()
53
+ os .rmdir (location )
53
54
if scheme not in vcs .all_schemes :
54
55
raise Exception ("Not a supported/known scheme." )
55
56
@@ -58,6 +59,6 @@ def fetch_via_vcs(url):
58
59
vcs_type = vcs_name
59
60
60
61
backend = vcs .get_backend_for_scheme (scheme )
61
- backend .obtain (dest = temp , url = misc .hide_url (url ))
62
+ backend .obtain (dest = location , url = misc .hide_url (url ))
62
63
63
- return VCSResponse (dest_dir = temp , vcs_type = vcs_type , domain = domain )
64
+ return VCSResponse (dest_dir = location , vcs_type = vcs_type , domain = domain )
0 commit comments