Skip to content

Commit

Permalink
Merge pull request #42 from Xpertians/summary-results
Browse files Browse the repository at this point in the history
Summary results printed to screen
  • Loading branch information
oscarvalenzuelab authored Apr 20, 2024
2 parents 5a6093a + f1094d9 commit d75309d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def read_version():
'zstandard',
'requests',
'oslili',
'tabulate',
],
extras_require={
'test': ['pytest'],
Expand Down
2 changes: 1 addition & 1 deletion src/xmonkey_curator/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.9'
__version__ = '0.1.10'
65 changes: 63 additions & 2 deletions src/xmonkey_curator/report_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import json
import logging
from tabulate import tabulate
from datetime import datetime
from .file_utilities import FileUtilities
from .__version__ import __version__
Expand Down Expand Up @@ -42,8 +43,68 @@ def save_report(self, filename='report.json'):
print(f"Report saved to {filename}")

def print_report(self):
report_data = self.generate_report_data()
print(json.dumps(report_data, indent=4))
data = self.generate_report_data()
summary_data = {
"Scan Date": data["scan_date"],
"Tool Name": data["tool_name"],
"Version": data["version"],
"Files Scanned": len(data["results"]["scan_results"])
}
summary_table = tabulate(
[summary_data.values()],
headers=summary_data.keys(),
tablefmt="grid"
)
detailed_results = []
for result in data["results"]["scan_results"]:
detailed_results.append([
result["file_path"],
result["mime_type"],
result["size"]
])
detailed_table = tabulate(
detailed_results,
headers=["File Path", "MIME Type", "Size"],
tablefmt="grid"
)
signature_summary = {}
if "symbols_matching" in data["results"]:
for symbol in data["results"]["symbols_matching"]:
signature = (
f"{symbol['signature_properties']['package']} - "
f"{symbol['signature_properties']['publisher']}"
)
license = symbol['signature_properties']['license']
symbol_count = len(symbol["matched_symbols"])
if signature not in signature_summary:
signature_summary[signature] = {
"license": license,
"file_count": 0,
"total_symbols": 0
}
signature_summary[signature]["file_count"] += 1
signature_summary[signature]["total_symbols"] += symbol_count
signature_data = [
[
sig,
details["license"],
details["file_count"],
details["total_symbols"]
]
for sig, details in signature_summary.items()
]
signature_table = tabulate(
signature_data,
headers=["Signature", "License", "Files Found", "Total Symbols"],
tablefmt="grid"
)
print("Summary Information:")
print(summary_table)
print("\nDetailed Scan Results:")
print(detailed_table)
if "symbols_matching" in data["results"]:
print("\nSignature Matches:")
print(signature_table)


def create_report_entry(file_path, mime_type, checksum, words):
Expand Down

0 comments on commit d75309d

Please sign in to comment.