1313from bs4 import BeautifulSoup
1414from packageurl import PackageURL
1515
16- from scanpipe .pipes .fetch import fetch_http
17-
16+ from minecode_pipelines .utils import get_temp_file
1817
1918"""
2019Visitors for cpan and cpan-like perl package repositories.
@@ -33,9 +32,19 @@ def get_cpan_packages(cpan_repo=CPAN_REPO, logger=None):
3332 path_prefixes with author page path from this list.
3433 """
3534 cpan_packages_url = cpan_repo + "modules/02packages.details.txt.gz"
36- cpan_packages_gz_download = fetch_http (cpan_packages_url )
37- with gzip .open (cpan_packages_gz_download , "rb" ) as file_content :
38- packages_content = file_content .read ()
35+ packages_archive = get_temp_file (file_name = "cpan_packages" , extension = ".gz" )
36+ packages_content = get_temp_file (file_name = "cpan_packages" , extension = ".txt" )
37+ response = requests .get (cpan_packages_url , stream = True )
38+ with open (packages_archive , 'wb' ) as f :
39+ for chunk in response .iter_content (chunk_size = 8192 ):
40+ f .write (chunk )
41+
42+ with gzip .open (packages_archive , "rb" ) as f_in :
43+ with open (packages_content , "wb" ) as f_out :
44+ f_out .writelines (f_in )
45+
46+ with open (packages_content , 'r' , encoding = 'utf-8' ) as file :
47+ packages_content = file .read ()
3948
4049 package_path_by_name = {}
4150
0 commit comments