Metadata-Version: 2.5
Name: pyimporters-mesh
Version: 1.6.278
Summary: Sherpa MeSH knowledge import plugin
Author-email: Olivier Terrier <olivier.terrier@kairntech.com>
License: Proprietary
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Requires-Dist: collections-extended
Requires-Dist: lxml
Requires-Dist: pyimporters-plugins<1.7.0,>=1.6.0
Provides-Extra: sbom
Requires-Dist: cyclonedx-bom; extra == 'sbom'
Requires-Dist: pip-audit; extra == 'sbom'
Provides-Extra: test
Requires-Dist: pip; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: ruff; extra == 'test'
Description-Content-Type: text/markdown

# pyimporters-mesh

[![license](https://img.shields.io/badge/license-proprietary-red)](LICENSE)
[![version](https://img.shields.io/pypi/v/pyimporters-mesh)](https://pypi.org/project/pyimporters-mesh/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyimporters-mesh)](https://pypi.org/project/pyimporters-mesh/)

Sherpa knowledge import plugin for the [MeSH](https://www.nlm.nih.gov/mesh/) thesaurus (NLM XML descriptor files).

It registers one parser through the `pyimporters.plugins` entry point group:

| Plugin | Class                                     | Extensions   |
|--------|-------------------------------------------|--------------|
| `mesh` | `pyimporters_mesh.mesh:MeSHKnowledgeParser` | `xml`, `zip` |

Each `DescriptorRecord` becomes a `Term` with the `TreeNumber`, `Branch` and `Category`
properties. A `zip` archive may hold one or several XML files.

The user documentation (French and English) lives in [docs/sherpa](docs/sherpa).

## Requirements

- Python 3.12+
- `pyimporters_plugins` (>=1.6.0,<1.7.0), `lxml`, `collections-extended`

## Installation

```
pip install pyimporters-mesh
```

## Usage

```python
from pathlib import Path

from progress.bar import Bar

from pyimporters_mesh.mesh import MeSHKnowledgeParser, MeSHOptions

parser = MeSHKnowledgeParser()
options = MeSHOptions(branches="C,D")  # diseases, chemicals and drugs
terms = list(parser.parse(Path("desc2026.zip"), options.model_dump(), Bar("Processing")))
```

| Option     | Default      | Description                                                                 |
|------------|--------------|-----------------------------------------------------------------------------|
| `branches` | all branches | Comma-separated MeSH branch letters (case-insensitive); an unknown letter raises `ValueError` |

## Development

The build is driven by [Task](https://taskfile.dev) and [uv](https://docs.astral.sh/uv/),
with the shared stages coming from the `python-archetype` submodule:

```
git submodule update --init
```

```
task stages          # print the pipeline stages, in order
task                 # run the pipeline up to (but excluding) py:publish
task -- --skip-tests # same, without the test stage
task up-to -- lint   # run the pipeline up to and including one stage
task jenkins         # run every stage, exactly what Jenkins runs
```

Individual stages:

| Task                            | Description                                           |
|---------------------------------|-------------------------------------------------------|
| `task py:sync`                  | Install the workspace and its dependencies (uv sync)  |
| `task py:lint`                  | `ruff check` and `ruff format --check`                |
| `task py:format`                | Reformat the code with ruff                           |
| `task py:test`                  | Run the test suite (also records the help examples)   |
| `task py:help`                  | Update the generated blocks of the Sherpa help pages  |
| `task py:help-check`            | Check that the help pages match the code              |
| `task py:sbom`                  | Generate a CycloneDX SBOM of the resolved environment |
| `task py:check-vulnerabilities` | Check for known CVEs                                  |
| `task py:check-updates`         | Check for dependency updates                          |
| `task py:build`                 | Build the wheel and sdist (uv build)                  |
| `task py:publish`               | Publish the distributions (uv publish)                |

`uv.lock` is not versioned here, so `py:sync` always resolves dependencies from scratch.
