Skip to content

Conversation

@Speedrunyourknowledge
Copy link
Owner

@Speedrunyourknowledge Speedrunyourknowledge commented Dec 2, 2025

Description

When the user runs Magika in the CLI, they now have the option of providing a --summary flag.
If this flag is active (and the --json flag is not active), then Magika's normal output will be followed by a list of detected file types and their count.

When the user runs Majika in Python, they can now use the scan_directory function, which takes in 2 parameters: directory and recursive_scan. Adding a directory tells the function to scan all the files in the directory, and setting recursive_scan to True tells the function to recursively scan all subdirectories in the directory.

Implementation

Updated rust/cli/src/main.rs to keep track of how many times each file type was detected.
Configured the summary list to display in order of descending file count, followed by alphabetical order.

Added a new scan_directory function to python/src/magika/magika.py.
Added a unit test to python/tests/test_magika_python_module.py.
Added relevant test files to tests_data/directory.

Screenshots

CLI: Output of cargo run -- --recursive --summary ../../tests_data

sde 2 pr-1

Python: Printing the list returned by magika.scan_directory(tests_data, True)

  • File path is on the left, and file type is on the right

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants