kopia lustrzana https://github.com/jupyterhub/repo2docker
Apply suggestions from code review
Co-authored-by: Samuel Gaist <samuel.gaist@idiap.ch>pull/1335/head^2
rodzic
e85495cf04
commit
9e0bd86a87
|
@ -10,7 +10,7 @@ from zipfile import ZipFile, is_zipfile
|
|||
from urllib.parse import urlparse, urlunparse
|
||||
|
||||
def get_hashed_slug(url, changes_with_content):
|
||||
"""Return a unique slug that is invariant to query parameters in the url"""
|
||||
"""Returns a unique slug that is invariant to query parameters in the url"""
|
||||
parsed_url = urlparse(url)
|
||||
stripped_url = urlunparse(
|
||||
(parsed_url.scheme, parsed_url.netloc, parsed_url.path, "", "", "")
|
||||
|
@ -30,13 +30,9 @@ def fetch_zipfile(session, url, dst_dir):
|
|||
return dst_filename
|
||||
|
||||
|
||||
def handle_items(_, item):
|
||||
print(item)
|
||||
|
||||
|
||||
def extract_validate_and_identify_bundle(zip_filename, dst_dir):
|
||||
if not os.path.exists(zip_filename):
|
||||
raise RuntimeError("Download MECA bundle not found")
|
||||
raise RuntimeError("Downloaded MECA bundle not found")
|
||||
|
||||
if not is_zipfile(zip_filename):
|
||||
raise RuntimeError("MECA bundle is not a zip file")
|
||||
|
@ -80,7 +76,7 @@ class Meca(ContentProvider):
|
|||
def detect(self, spec, ref=None, extra_args=None):
|
||||
"""`spec` contains a faux protocol of meca+http[s] for detection purposes
|
||||
and we assume `spec` trusted as a reachable MECA bundle from an allowed origin
|
||||
(binderhub RepoProvider class already checking for this).
|
||||
(binderhub RepoProvider class is already checking for this).
|
||||
|
||||
An other HEAD check in made here in order to get the content-length header
|
||||
"""
|
||||
|
@ -90,8 +86,8 @@ class Meca(ContentProvider):
|
|||
parsed = parsed._replace(scheme=parsed.scheme[:-5])
|
||||
url = urlunparse(parsed)
|
||||
|
||||
r = self.session.head(url)
|
||||
changes_with_content = r.headers.get("ETag") or r.headers.get("Content-Length")
|
||||
headers = self.session.head(url).headers
|
||||
changes_with_content = headers.get("ETag") or headers.get("Content-Length")
|
||||
|
||||
self.hashed_slug = get_hashed_slug(url, changes_with_content)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue