File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 23
23
import gzip
24
24
import os
25
25
from datetime import datetime
26
+ from shutil import rmtree
26
27
27
28
import debian_inspector
28
29
from aboutcode import hashid
@@ -82,21 +83,23 @@ class DebianCollector:
82
83
83
84
def __init__ (self , index_location = None ):
84
85
if index_location :
86
+ self .index_download = None
85
87
self .index_location = index_location
86
88
else :
87
- self .index_location = self ._fetch_index ()
88
- self .index_location_given = bool ( index_location )
89
+ self .index_download = self ._fetch_index ()
90
+ self .index_location = self . index_download . path
89
91
90
92
def __del__ (self ):
91
- if self .index_location and not self . index_location_given :
92
- os . remove (self .index_location )
93
+ if self .index_download :
94
+ rmtree (self .index_download . directory )
93
95
94
96
def _fetch_index (self , uri = DEBIAN_LSLR_URL ):
95
97
"""
96
- Return a temporary location where the debian index was saved.
98
+ Fetch the Debian index at `uri` and return a Download with information
99
+ about where it was saved.
97
100
"""
98
101
index = fetch_http (uri )
99
- return index . path
102
+ return index
100
103
101
104
def get_packages (self , previous_index_last_modified_date = None , logger = None ):
102
105
"""Yield Package objects from debian index"""
You can’t perform that action at this time.
0 commit comments