Metadata-Version: 2.2
Name: loadnsi
Version: 0.0.2
Summary: Utility for downloading and updating NSI fixtures
Home-page: https://github.com/Friskes/loadnsi
Author: Friskes
Author-email: Friskes <friskesx@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Friskes
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/Friskes/loadnsi
Project-URL: Changelog, https://github.com/Friskes/loadnsi/releases/
Project-URL: Issues, https://github.com/Friskes/loadnsi/issues
Keywords: Django,Fixture,NSI
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Documentation
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click==8.1.8
Requires-Dist: bs4==0.0.2
Requires-Dist: httpx==0.28.0
Requires-Dist: aiofiles==24.1.0
Requires-Dist: tenacity==9.0.0
Requires-Dist: rich==13.9.4
Requires-Dist: python-dotenv==1.0.1
Provides-Extra: dev
Requires-Dist: pre-commit>=3.5.0; extra == "dev"
Requires-Dist: ruff==0.8.0; extra == "dev"
Requires-Dist: pytest>=7.0.1; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
Provides-Extra: ci
Requires-Dist: ruff==0.8.0; extra == "ci"
Requires-Dist: pytest>=7.0.1; extra == "ci"
Requires-Dist: mypy>=1.10.0; extra == "ci"
Requires-Dist: pytest-cov>=5.0.0; extra == "ci"

# Utility for downloading and updating NSI fixtures

<div align="center">

| Project   |     | Status                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|-----------|:----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CI/CD     |     | [![Latest Release](https://github.com/Friskes/loadnsi/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/Friskes/loadnsi/actions/workflows/publish-to-pypi.yml)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Quality   |     | [![Coverage](https://codecov.io/github/Friskes/loadnsi/graph/badge.svg?token=vKez4Pycrc)](https://codecov.io/github/Friskes/loadnsi)                                                                                                                                                                                                                                                                                                                               |
| Package   |     | [![PyPI - Version](https://img.shields.io/pypi/v/loadnsi?labelColor=202235&color=edb641&logo=python&logoColor=edb641)](https://badge.fury.io/py/loadnsi) ![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/loadnsi?labelColor=202235&color=edb641&logo=python&logoColor=edb641) ![Project PyPI - Downloads](https://img.shields.io/pypi/dm/loadnsi?logo=python&label=downloads&labelColor=202235&color=edb641&logoColor=edb641)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Meta      |     | [![types - Mypy](https://img.shields.io/badge/types-Mypy-202235.svg?logo=python&labelColor=202235&color=edb641&logoColor=edb641)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-202235.svg?logo=python&labelColor=202235&color=edb641&logoColor=edb641)](https://spdx.org/licenses/) [![code style - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json&labelColor=202235)](https://github.com/astral-sh/ruff) |

</div>

> Команда [loadnsi](#About-command) позволяет загружать и обновлять фикстуры [НСИ](https://nsi.rosminzdrav.ru) в которых записи имеют стабильный pk вашей внутренней системы бд.


## Подготовка к запуску
1. Установка пакета
    ```bash
    pip install loadnsi
    ```

2. Создание файла переменных среды
    .env файл с содержимым:
    ```bash
    PATH_TO_LOADNSI_CONFIG=path/to/your/config/file.py
    # Требуется только если вы собираетесь использовать официальный API НСИ (Запуск команды с флагом `--use_official_api`)
    NSI_API_USER_KEY=some-key
    ```

3. Создание файла конфигурации `loadnsi_config.py`
    ```python
    NSI_FIXTURES_FOLDER = 'path/to/your/nsi/folder'
    NSI_PASSPORTS = {
        'file': 'Локальное название файла с паспортами справочников',
        'model': 'Локальное название модели с паспортами справочников',
        # Опциональные параметры (fields):
        'fields': <Iterable объект состоящий из полей паспорта (str) которые необходимо оставить в объекте паспорта>,
    }
    DICT_INTERNAL_PK = 'your pk field name *not alias*'
    PASSPORTS_REL = 'your fieldname for ForeignKey to PARENT_DICT_CLS'
    PARENT_DICT_CLS = 'your base cls modelname for dicts'
    NSI_DICTIONARIES = {
        'Локальное название файла справочника 1': {
            'model': 'Приложение.МодельСправочника1',
            'oid': 'OID Справочника 1',
            # Опциональные параметры (filter и fields):
            'filter': <Callable объект принимает справочник (dict) должен вернуть (bool) оставлять ли этот объект в списке>,
            'fields': <Iterable объект состоящий из полей справочника (str) которые необходимо оставить в объекте справочника>,
            'create_sql': <Boolean объект (bool), если True будет создан дублирующий файл справочника в SQL формате>,
        },
        'Локальное название файла справочника 2': {
            'model': 'Приложение.МодельСправочника2',
            'oid': 'OID Справочника 2',
        },
    }
    ```


## About command
Подробности про каждую опцию команды можно узнать вызвав команду с флагом `--help`


## Contributing
We would love you to contribute to `loadnsi`, pull requests are very welcome! Please see [CONTRIBUTING.md](https://github.com/Friskes/loadnsi/blob/main/CONTRIBUTING.md) for more information.
