Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Foundation
EMO Team
eclipsefdn-ort
Commits
4db82b97
Commit
4db82b97
authored
Jul 21, 2022
by
Boris Baldassari
Browse files
Add script to export ort analyzer deps to dash.
parent
1433abdb
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/extract_packages_from_ort_results.py
0 → 100644
View file @
4db82b97
import
json
import
sys
import
re
file_in
=
sys
.
argv
[
1
]
if
not
file_in
:
print
(
'Need a file to work on.'
)
print
(
f
'Usage:
{
sys
.
argv
[
0
]
}
results.json'
)
exit
()
#print(f"Reading results from {file_in}.")
with
open
(
file_in
,
'r'
)
as
f
:
results_f
=
f
.
read
()
# parse file
results
=
json
.
loads
(
results_f
)
npm_id_re
=
re
.
compile
(
'^NPM:(?P<namespace>[^:]*):(?P<name>[^:]*):(?P<version>[^:]*)$'
)
#print(f"Found {len(results['analyzer']['result']['packages'])} packages.")
for
i
in
results
[
'analyzer'
][
'result'
][
'packages'
]:
# print(i['package']['id'])
npm_id_match
=
npm_id_re
.
match
(
i
[
'package'
][
'id'
])
ns
=
npm_id_match
.
group
(
'namespace'
)
if
npm_id_match
.
group
(
'namespace'
)
else
'-'
print
(
f
"npm/npmjs/
{
ns
}
/
{
npm_id_match
.
group
(
'name'
)
}
/
{
npm_id_match
.
group
(
'version'
)
}
"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment