improve output by using deepdiff

This commit is contained in:
Felix Pankratz 2023-07-02 15:45:17 +02:00
parent 403cf48502
commit 2972e222a3
2 changed files with 9 additions and 5 deletions

View File

@ -2,6 +2,8 @@
import requests import requests
import json import json
import time import time
from pprint import pprint
from deepdiff import DeepDiff
# https://www.npmjs.com/package/darcyclarke-manifest-pkg/v/2.1.15/index # https://www.npmjs.com/package/darcyclarke-manifest-pkg/v/2.1.15/index
# hex checksum = file name # hex checksum = file name
@ -72,7 +74,6 @@ def get_actual_manifest(pkg, ver):
return version, dependencies, scripts, name return version, dependencies, scripts, name
def main(): def main():
import sys import sys
mismatch = False mismatch = False
@ -91,15 +92,17 @@ def main():
if actual_dependencies != reported_dependencies: if actual_dependencies != reported_dependencies:
mismatch = True mismatch = True
dep_diff = DeepDiff(reported_dependencies, actual_dependencies, verbose_level=2)
print('Dependency mismatch detected for {}!'.format(pkg)) print('Dependency mismatch detected for {}!'.format(pkg))
print('Reported dependencies: {}'.format(reported_dependencies)) pprint(dep_diff, indent=2)
print('Actual dependencies: {}'.format(actual_dependencies))
if actual_scripts != reported_scripts: if actual_scripts != reported_scripts:
mismatch = True mismatch = True
scripts_diff = DeepDiff(reported_scripts, actual_scripts, verbose_level=2)
print('Scripts mismatch detected for {}!'.format(pkg)) print('Scripts mismatch detected for {}!'.format(pkg))
print('Reported scripts: {}'.format(reported_scripts)) pprint(scripts_diff, indent=2)
print('Actual scripts: {}'.format(actual_scripts))
if actual_name != reported_name: if actual_name != reported_name:
mismatch = True mismatch = True

View File

@ -1 +1,2 @@
requests requests
deepdiff