10
10
from urllib .parse import urlparse , urlunparse
11
11
12
12
def get_hashed_slug (url , changes_with_content ):
13
- """Return a unique slug that is invariant to query parameters in the url"""
13
+ """Returns a unique slug that is invariant to query parameters in the url"""
14
14
parsed_url = urlparse (url )
15
15
stripped_url = urlunparse (
16
16
(parsed_url .scheme , parsed_url .netloc , parsed_url .path , "" , "" , "" )
@@ -30,13 +30,9 @@ def fetch_zipfile(session, url, dst_dir):
30
30
return dst_filename
31
31
32
32
33
- def handle_items (_ , item ):
34
- print (item )
35
-
36
-
37
33
def extract_validate_and_identify_bundle (zip_filename , dst_dir ):
38
34
if not os .path .exists (zip_filename ):
39
- raise RuntimeError ("Download MECA bundle not found" )
35
+ raise RuntimeError ("Downloaded MECA bundle not found" )
40
36
41
37
if not is_zipfile (zip_filename ):
42
38
raise RuntimeError ("MECA bundle is not a zip file" )
@@ -80,7 +76,7 @@ def __init__(self):
80
76
def detect (self , spec , ref = None , extra_args = None ):
81
77
"""`spec` contains a faux protocol of meca+http[s] for detection purposes
82
78
and we assume `spec` trusted as a reachable MECA bundle from an allowed origin
83
- (binderhub RepoProvider class already checking for this).
79
+ (binderhub RepoProvider class is already checking for this).
84
80
85
81
An other HEAD check in made here in order to get the content-length header
86
82
"""
@@ -90,8 +86,8 @@ def detect(self, spec, ref=None, extra_args=None):
90
86
parsed = parsed ._replace (scheme = parsed .scheme [:- 5 ])
91
87
url = urlunparse (parsed )
92
88
93
- r = self .session .head (url )
94
- changes_with_content = r . headers .get ("ETag" ) or r . headers .get ("Content-Length" )
89
+ headers = self .session .head (url ). headers
90
+ changes_with_content = headers .get ("ETag" ) or headers .get ("Content-Length" )
95
91
96
92
self .hashed_slug = get_hashed_slug (url , changes_with_content )
97
93
0 commit comments