2
2
3
3
import json
4
4
import os
5
- import tarfile
5
+ import tarfile as esatar
6
6
import sys
7
7
import re
8
8
import warnings
27
27
from astropy .coordinates .name_resolve import sesame_database
28
28
29
29
30
+ # We do trust the ESA tar files, this is to avoid the new to Python 3.12 deprecation warning
31
+ # https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter
32
+ if hasattr (esatar , "fully_trusted_filter" ):
33
+ esatar .TarFile .extraction_filter = staticmethod (esatar .fully_trusted_filter )
34
+
35
+
30
36
@async_to_sync
31
37
class ESASkyClass (BaseQuery ):
32
38
@@ -1526,7 +1532,7 @@ def _get_maps_for_mission(self, maps_table, mission, download_dir, cache, json,
1526
1532
if file_name == "" :
1527
1533
file_name = self ._extract_file_name_from_url (product_url )
1528
1534
if file_name .lower ().endswith (self .__TAR_STRING ):
1529
- with tarfile .open (fileobj = BytesIO (response .content )) as tar :
1535
+ with esatar .open (fileobj = BytesIO (response .content )) as tar :
1530
1536
for member in tar .getmembers ():
1531
1537
tar .extract (member , directory_path )
1532
1538
maps .append (self ._open_fits (Path (directory_path , member .name ), verbose = verbose ))
@@ -1574,7 +1580,7 @@ def _get_herschel_map(self, product_url, directory_path, cache, verbose=False):
1574
1580
stream = True , headers = self ._get_header ())
1575
1581
response .raise_for_status ()
1576
1582
1577
- with tarfile .open (fileobj = BytesIO (response .content )) as tar :
1583
+ with esatar .open (fileobj = BytesIO (response .content )) as tar :
1578
1584
for member in tar .getmembers ():
1579
1585
member_name = member .name .lower ()
1580
1586
if 'hspire' in member_name or 'hpacs' in member_name :
@@ -1592,7 +1598,7 @@ def _get_herschel_spectra(self, product_url, directory_path, cache, verbose=Fals
1592
1598
1593
1599
response .raise_for_status ()
1594
1600
1595
- with tarfile .open (fileobj = BytesIO (response .content )) as tar :
1601
+ with esatar .open (fileobj = BytesIO (response .content )) as tar :
1596
1602
for member in tar .getmembers ():
1597
1603
member_name = member .name .lower ()
1598
1604
if ('hspire' in member_name or 'hpacs' in member_name
0 commit comments