-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to find versions of packages
- Loading branch information
1 parent
5076b95
commit 48f3445
Showing
3 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
vendor,product,version | ||
plot,plotly,4.14.3 | ||
pocoo,jinja2,2.11.3 | ||
aiohttp_project,aiohttp,3.7.4.post0 | ||
pyyaml,pyyaml,5.4.1 | ||
vendor,product | ||
plot,plotly | ||
pocoo,jinja2 | ||
aiohttp_project,aiohttp | ||
pyyaml,pyyaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (C) 2021 Intel Corporation | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
# Script to add versions to requirements.csv | ||
|
||
import csv | ||
import os | ||
import pkg_resources | ||
|
||
REQ_CSV = os.path.abspath(os.path.join(os.path.dirname(__file__), "requirements.csv")) | ||
CACHE_CSV = os.path.join(os.path.expanduser("~"), ".cache", "cve-bin-tool", "requirements.csv") | ||
|
||
def get_cache_csv_data(file): | ||
data = [] | ||
with open(file, "r") as f: | ||
r = csv.reader(f) | ||
next(r) | ||
for row in r: | ||
data.append((row[0], row[1], pkg_resources.get_distribution(row[1]).version)) | ||
return data | ||
|
||
cache_csv_data = get_cache_csv_data(REQ_CSV) | ||
|
||
# writes a cache CSV file | ||
with open(CACHE_CSV, "w") as f: | ||
writer = csv.writer(f) | ||
fieldnames = ["vendor", "product", "version"] | ||
writer = csv.DictWriter(f, fieldnames=fieldnames) | ||
writer.writeheader() | ||
for row in cache_csv_data: | ||
writer.writerow({"vendor": row[0], "product": row[1], "version": row[2]}) |