diff --git a/repo2docker/contentproviders/__init__.py b/repo2docker/contentproviders/__init__.py index 3e88bc93..b4c11878 100755 --- a/repo2docker/contentproviders/__init__.py +++ b/repo2docker/contentproviders/__init__.py @@ -3,7 +3,7 @@ from .figshare import Figshare from .git import Git from .hydroshare import Hydroshare +from .meca import Meca from .mercurial import Mercurial from .swhid import Swhid from .zenodo import Zenodo -from .meca import Meca diff --git a/repo2docker/contentproviders/meca.py b/repo2docker/contentproviders/meca.py index 515b8360..e362a7e6 100644 --- a/repo2docker/contentproviders/meca.py +++ b/repo2docker/contentproviders/meca.py @@ -1,13 +1,16 @@ -from .base import ContentProvider -from requests import Session import os -from hashlib import md5 -from os import path -import tempfile import shutil +import tempfile import xml.etree.ElementTree as ET -from zipfile import ZipFile, is_zipfile +from hashlib import md5 +from os import path from urllib.parse import urlparse, urlunparse +from zipfile import ZipFile, is_zipfile + +from requests import Session + +from .base import ContentProvider + def get_hashed_slug(url, changes_with_content): """Return a unique slug that is invariant to query parameters in the url""" @@ -18,6 +21,7 @@ def get_hashed_slug(url, changes_with_content): return "meca-" + md5(f"{stripped_url}-{changes_with_content}".encode()).hexdigest() + def fetch_zipfile(session, url, dst_dir): resp = session.get(url, headers={"accept": "application/zip"}, stream=True) resp.raise_for_status()