xmonkey-lidy
is a command-line and Python library tool for identifying open-source licenses in text files using Sørensen-Dice proximity matching and pattern-based matching. It supports SPDX license detection with debug options to help investigate how matches were made.
- Identify open-source licenses in files using Sørensen-Dice similarity or pattern matching.
- Validate files against specific SPDX licenses.
- Download and update the SPDX license data.
- Generate detailed debug information showing matched and excluded patterns.
- Python 3.8 or higher
pip3
(Python package installer)
You can install the tool directly using pip3
:
pip3 install xmonkey-lidy
Once installed, the xmonkey-lidy
command-line tool will be available globally.
Alternatively, if you're using a virtual environment:
python3 -m venv env
source env/bin/activate
pip3 install xmonkey-lidy
-
Clone the repository or download the package:
git clone https://github.com/yourusername/xmonkey-lidy.git cd xmonkey-lidy
-
Install the package:
pip3 install .
The following are the commands available in xmonkey-lidy
:
xmonkey-lidy update --data-dir <path_to_store_data> --publisher <publisher_name>
Example:
xmonkey-lidy update --data-dir ./data --publisher "MyCustomPublisher"
xmonkey-lidy identify <path_to_file>
Example:
xmonkey-lidy identify ./path/to/LICENSE.txt
xmonkey-lidy validate <path_to_file> <SPDX_license>
Example:
xmonkey-lidy validate ./path/to/LICENSE.txt Apache-2.0
xmonkey-lidy produce <SPDX_license>
Example:
xmonkey-lidy produce MIT
You can use xmonkey-lidy
as a dependency in other Python projects by including it in your requirements.txt
or setup.py
file.
Add the following line to your requirements.txt
file:
xmonkey-lidy
Then, install the dependencies:
pip3 install -r requirements.txt
In your setup.py
, you can add xmonkey-lidy
as a dependency:
from setuptools import setup, find_packages
setup(
name='your_project_name',
version='1.0',
packages=find_packages(),
install_requires=[
'xmonkey-lidy'
],
)
Once installed, you can use xmonkey-lidy
programmatically by importing the necessary classes in your Python project. For example:
from xmonkey_lidy.matcher import LicenseMatcher
# Initialize the LicenseMatcher
matcher = LicenseMatcher()
# Identify the license of a file
result = matcher.identify_license('./path/to/LICENSE.txt')
# Print the result
print(result)
In this example, you can interact with the LicenseMatcher
class directly and perform license identification, validation, and more within your own code.
from xmonkey_lidy.matcher import LicenseMatcher
# Initialize the LicenseMatcher
matcher = LicenseMatcher()
# Validate a file against a specific SPDX license
validation_result = matcher.validate_patterns('./path/to/LICENSE.txt', 'Apache-2.0')
# Print validation result
print(validation_result)
By importing and using xmonkey-lidy
, you can integrate license identification and validation capabilities directly into your Python projects.
This project is licensed under the MIT License - see the LICENSE file for details.