kopia lustrzana https://github.com/jupyterhub/repo2docker
only use data/contents directory
rodzic
316b1a0f34
commit
fdb92525c6
|
@ -1,4 +1,6 @@
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
from urllib.request import urlopen, Request, urlretrieve
|
from urllib.request import urlopen, Request, urlretrieve
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
|
@ -55,7 +57,7 @@ class Hydroshare(ContentProvider):
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
if any([url.startswith(s) for s in host["hostname"]]):
|
if any([url.startswith(s) for s in host["hostname"]]):
|
||||||
self.resource_id = url.rsplit("/", maxsplit=1)[1]
|
self.resource_id = url.rsplit("/", maxsplit=2)[1]
|
||||||
return {"resource": self.resource_id, "host": host}
|
return {"resource": self.resource_id, "host": host}
|
||||||
|
|
||||||
def fetch(self, spec, output_dir, yield_output=False):
|
def fetch(self, spec, output_dir, yield_output=False):
|
||||||
|
@ -68,7 +70,12 @@ class Hydroshare(ContentProvider):
|
||||||
bag_url = "{}{}".format(host["django_irods"], resource_id)
|
bag_url = "{}{}".format(host["django_irods"], resource_id)
|
||||||
filehandle, _ = urlretrieve(bag_url)
|
filehandle, _ = urlretrieve(bag_url)
|
||||||
zip_file_object = zipfile.ZipFile(filehandle, 'r')
|
zip_file_object = zipfile.ZipFile(filehandle, 'r')
|
||||||
zip_file_object.extractall(output_dir)
|
|
||||||
|
zip_file_object.extractall("temp")
|
||||||
|
files = os.listdir(os.path.join("temp", self.resource_id, "data", "contents"))
|
||||||
|
for f in files:
|
||||||
|
shutil.move("temp" + f, output_dir)
|
||||||
|
shutil.rmtree("temp")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def content_id(self):
|
def content_id(self):
|
||||||
|
|
Ładowanie…
Reference in New Issue