2
2
3
3
import enum
4
4
import functools
5
+ import gzip
5
6
import itertools
6
7
import json
7
8
import logging
@@ -935,7 +936,7 @@ def _write_http_cache_info(
935
936
def _try_load_parsed_links_cache (parsed_links_path : Path ) -> Optional [List [Link ]]:
936
937
page_links : Optional [List [Link ]] = None
937
938
try :
938
- with parsed_links_path .open ("r " ) as f :
939
+ with gzip .open (parsed_links_path , mode = "rt" , encoding = "utf-8 " ) as f :
939
940
logger .debug ("reading page links from cache %s" , parsed_links_path )
940
941
cached_links = json .load (f )
941
942
page_links = []
@@ -967,7 +968,7 @@ def _write_parsed_links_cache(
967
968
page_links .append (link )
968
969
969
970
logger .debug ("writing page links to %s" , parsed_links_path )
970
- with parsed_links_path .open ("w " ) as f :
971
+ with gzip .open (parsed_links_path , mode = "wt" , encoding = "utf-8 " ) as f :
971
972
json .dump (cacheable_links , f )
972
973
973
974
return page_links
@@ -977,7 +978,7 @@ def _try_load_installation_candidate_cache(
977
978
cached_candidates_path : Path ,
978
979
) -> Optional [List [InstallationCandidate ]]:
979
980
try :
980
- with cached_candidates_path .open ("r " ) as f :
981
+ with gzip .open (cached_candidates_path , mode = "rt" , encoding = "utf-8 " ) as f :
981
982
serialized_candidates = json .load (f )
982
983
logger .debug ("read serialized candidates from %s" , cached_candidates_path )
983
984
package_links : List [InstallationCandidate ] = []
@@ -1011,7 +1012,7 @@ def _write_installation_candidate_cache(
1011
1012
)
1012
1013
for candidate in candidates
1013
1014
]
1014
- with cached_candidates_path .open ("w " ) as f :
1015
+ with gzip .open (cached_candidates_path , mode = "wt" , encoding = "utf-8 " ) as f :
1015
1016
logger .debug ("writing serialized candidates to %s" , f .name )
1016
1017
json .dump (serialized_candidates , f )
1017
1018
return candidates
0 commit comments