Skip to content

Commit f8d0760

Browse files
committed
Remove functions to create PurlValidator from purl list
* This was done for dev purposes Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent 596ab39 commit f8d0760

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

src/purl_validator/__init__.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def create_purl_map_entry(purl):
5656

5757
def create_purl_map(purls):
5858
# Ensure elements of `purls` are PackageURLs:
59-
purls = [check_purl(purl) for purl in purls]
59+
purls = (check_purl(purl) for purl in purls)
6060

6161
# purl map entries must be unique, sorted, and converted to bytes before going into the Map
6262
purl_map_entries = set(create_purl_map_entry(purl) for purl in purls)
@@ -71,28 +71,11 @@ def create_purl_map(purls):
7171

7272

7373
class PurlValidator:
74-
def __init__(self, purls=None):
75-
self.created_maps = []
76-
77-
if purls:
78-
# Create purl map from list of purls
79-
purl_map_loc = self.create_purl_map(purls=purls)
80-
else:
81-
purl_map_loc = PURL_MAP_LOCATION
82-
83-
self.purl_map = self.load_purl_map(location=purl_map_loc)
84-
85-
def __del__(self):
86-
for loc in self.created_maps:
87-
fileutils.delete(loc.parent)
88-
89-
def create_purl_map(self, purls):
90-
purl_map_loc = create_purl_map(purls)
91-
self.created_maps.append(purl_map_loc)
92-
return purl_map_loc
74+
def __init__(self, purl_map_loc=PURL_MAP_LOCATION):
75+
self.purl_map = self.load_map(location=purl_map_loc)
9376

9477
@classmethod
95-
def load_purl_map(cls, location):
78+
def load_map(cls, location):
9679
with open(location, "rb") as f:
9780
mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
9881
m = ducer.Map(mm)

0 commit comments

Comments
 (0)