Skip to content

Commit 1a9bba0

Browse files
stevejpurvessgaist
andcommitted
Apply suggestions from code review
Co-authored-by: Samuel Gaist <samuel.gaist@idiap.ch>
1 parent a806b14 commit 1a9bba0

File tree

1 file changed

+5
-9
lines changed
  • repo2docker/contentproviders

1 file changed

+5
-9
lines changed

repo2docker/contentproviders/meca.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def get_hashed_slug(url, changes_with_content):
16-
"""Return a unique slug that is invariant to query parameters in the url"""
16+
"""Returns a unique slug that is invariant to query parameters in the url"""
1717
parsed_url = urlparse(url)
1818
stripped_url = urlunparse(
1919
(parsed_url.scheme, parsed_url.netloc, parsed_url.path, "", "", "")
@@ -34,13 +34,9 @@ def fetch_zipfile(session, url, dst_dir):
3434
return dst_filename
3535

3636

37-
def handle_items(_, item):
38-
print(item)
39-
40-
4137
def extract_validate_and_identify_bundle(zip_filename, dst_dir):
4238
if not os.path.exists(zip_filename):
43-
raise RuntimeError("Download MECA bundle not found")
39+
raise RuntimeError("Downloaded MECA bundle not found")
4440

4541
if not is_zipfile(zip_filename):
4642
raise RuntimeError("MECA bundle is not a zip file")
@@ -84,7 +80,7 @@ def __init__(self):
8480
def detect(self, spec, ref=None, extra_args=None):
8581
"""`spec` contains a faux protocol of meca+http[s] for detection purposes
8682
and we assume `spec` trusted as a reachable MECA bundle from an allowed origin
87-
(binderhub RepoProvider class already checking for this).
83+
(binderhub RepoProvider class is already checking for this).
8884
8985
An other HEAD check in made here in order to get the content-length header
9086
"""
@@ -94,8 +90,8 @@ def detect(self, spec, ref=None, extra_args=None):
9490
parsed = parsed._replace(scheme=parsed.scheme[:-5])
9591
url = urlunparse(parsed)
9692

97-
r = self.session.head(url)
98-
changes_with_content = r.headers.get("ETag") or r.headers.get("Content-Length")
93+
headers = self.session.head(url).headers
94+
changes_with_content = headers.get("ETag") or headers.get("Content-Length")
9995

10096
self.hashed_slug = get_hashed_slug(url, changes_with_content)
10197

0 commit comments

Comments
 (0)