forked from ctroupin/py-eddy-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
38 lines (31 loc) · 1022 Bytes
/
__init__.py
File metadata and controls
38 lines (31 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
EddyId \
nrt_global_allsat_phy_l4_20190223_20190226.nc \
20190223 adt ugos vgos longitude latitude . \
--cut 800 --fil 1
EddyId \
dt_med_allsat_phy_l4_20160515_20190101.nc \
20160515 adt None None longitude latitude . \
--cut 800 --fil 1
"""
import io
import lzma
import tarfile
from os import path
import requests
def get_path(name):
return path.join(path.dirname(__file__), name)
def get_remote_sample(path):
url = (
f"https://github.com/AntSimi/py-eddy-tracker-sample-id/raw/master/{path}.tar.xz"
)
content = requests.get(url).content
# Tar module could manage lzma tar, but it will apply un compress for each extractfile
tar = tarfile.open(mode="r", fileobj=io.BytesIO(lzma.decompress(content)))
# tar = tarfile.open(mode="r:xz", fileobj=io.BytesIO(content))
files_content = list()
for item in tar:
content = tar.extractfile(item)
content.filename = item.name
files_content.append(content)
return files_content