├── src ├── __init__.py └── nechestniy_znak │ ├── __init__.py │ ├── egais.py │ └── crpt.py ├── tests └── __init__.py ├── .gitignore ├── pyproject.toml ├── LICENSE ├── test.py ├── README.md └── .github └── workflows └── publish-to-pypi.yml /src/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/nechestniy_znak/__init__.py: -------------------------------------------------------------------------------- 1 | from .crpt import * 2 | from .egais import * 3 | 4 | __version__ = "1.0.3" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | 3 | # Packages 4 | *.egg 5 | *.egg-info 6 | dist 7 | build 8 | _build 9 | .cache 10 | *.so 11 | 12 | # Installer logs 13 | pip-log.txt 14 | 15 | # Unit test / coverage reports 16 | .coverage 17 | .tox 18 | .pytest_cache 19 | 20 | .DS_Store 21 | .idea/* 22 | .python-version 23 | .vscode/* 24 | 25 | /test.py 26 | /test_*.* 27 | 28 | setup.cfg 29 | MANIFEST.in 30 | /setup.py 31 | /docs/site/* 32 | /tests/fixtures/simple_project/setup.py 33 | .mypy_cache 34 | benchmark.py 35 | __pycache__/ -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=61.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "nechestniy_znak" 7 | version = "1.0.3" 8 | authors = [ 9 | { name="li0ard", email="li0ard@proton.me" }, 10 | ] 11 | maintainers = [ 12 | {name = "li0ard", email = "li0ard@proton.me"} 13 | ] 14 | description = "Библеотека обертка для API ГИС МТ “Честный Знак”" 15 | readme = "README.md" 16 | requires-python = ">=3.8" 17 | classifiers = [ 18 | "Development Status :: 4 - Beta", 19 | "Programming Language :: Python :: 3.8", 20 | "License :: OSI Approved :: MIT License", 21 | "Operating System :: OS Independent", 22 | ] 23 | dependencies = [ 24 | "requests", 25 | ] 26 | 27 | [project.urls] 28 | Homepage = "https://github.com/li0ard/nechestniy_znak" 29 | Issues = "https://github.com/li0ard/nechestniy_znak/issues" -------------------------------------------------------------------------------- /src/nechestniy_znak/egais.py: -------------------------------------------------------------------------------- 1 | import requests, urllib3 2 | from typing import Union 3 | urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 4 | 5 | class Egais: 6 | def __init__(self): 7 | pass 8 | 9 | def _get(self, url: str, params: str) -> Union[list, dict]: 10 | return requests.get(f"http://mobapi.fsrar.ru/api3/{url}?{params}", verify=False).json() 11 | 12 | def infoFromOldMark(self, pdf417: str, datamatrix: str) -> Union[list, dict]: 13 | return self._get("mark", f"DataMatrix={datamatrix}&Pdf417={pdf417}") 14 | 15 | def infoFromNewMark(self, datamatrix: str) -> Union[list, dict]: 16 | return self._get("marklong", f"Pdf417={datamatrix}") 17 | 18 | def infoFromAlcCode(self, alc_code: str) -> Union[list, dict]: 19 | return self._get("product_info", f"alc_code={alc_code}") 20 | 21 | def getChains(self, datamatrix: str) -> Union[list, dict]: 22 | return self._get("chain", f"barcode={datamatrix}") -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 li0ard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from src.nechestniy_znak import Crpt, Egais 3 | 4 | crpt = Crpt() 5 | 6 | def test_crptEAN13(): 7 | assert crpt.infoFromEAN13(46494139)["checkResult"] == True 8 | 9 | def test_crptDataMatrix(): 10 | assert crpt.infoFromDataMatrix("00000046209849Uon Union[list, dict]: 10 | return requests.get(f"https://mobile.api.crpt.ru/mobile/check?code={content}&codeType={type}").json() 11 | 12 | def _post(self, data: Union[dict, list]) -> Union[list, dict]: 13 | return requests.post(f"https://mobile.api.crpt.ru/mobile/check", json=data, headers={ 14 | "content-type": "application/json", 15 | "accept" : "application/json", 16 | "user-agent" : "Platform: iOS 17.2; AppVersion: 4.47.0; AppVersionCode: 7630; Device: iPhone 14 Pro;", 17 | "client" : "iOS 17.2; AppVersion: 4.47.0; Device: iPhone 14 Pro;" 18 | }).json() 19 | 20 | def infoFromDataMatrix(self, xyematrix: str) -> Union[list, dict]: 21 | return self._get(xyematrix, "datamatrix") 22 | 23 | def infoFromEAN13(self, ean13: str) -> Union[list, dict]: 24 | return self._get(ean13, "ean13") 25 | 26 | def infoFromQr(self, qr: str) -> Union[list, dict]: 27 | return self._get(qr, "qr") 28 | 29 | def infoFromReceipt(self, code: str) -> Union[list, dict]: 30 | return self._post({ 31 | "code" : code, 32 | "codeType": "qr", 33 | }) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 |

5 |    6 |

7 | 8 | Библеотека обертка для API ГИС МТ "Честный Знак" и API ЕГАИС 9 | 10 | [Документация](https://li0ard.gitbook.io/nechestniy_znak/) 11 | 12 | ### Установка 13 | 14 | **Требуется Python версии 3.8 или выше** 15 | ``` 16 | pip install nechestniy_znak 17 | ``` 18 | 19 | ### Пример 20 | ```py 21 | from nechestniy_znak import Crpt, Egais 22 | 23 | crpt = Crpt() 24 | print(crpt.infoFromEAN13("46494139")) 25 | print(crpt.infoFromDataMatrix("00000046209849Uon- 18 | python3 -m 19 | pip install 20 | build 21 | --user 22 | - name: Build a binary wheel and a source tarball 23 | run: python3 -m build 24 | - name: Store the distribution packages 25 | uses: actions/upload-artifact@v3 26 | with: 27 | name: python-package-distributions 28 | path: dist/ 29 | publish-to-pypi: 30 | name: >- 31 | Publish Python 🐍 distribution 📦 to PyPI 32 | if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes 33 | needs: 34 | - build 35 | runs-on: ubuntu-latest 36 | environment: 37 | name: pypi 38 | url: https://pypi.org/p/nechestniy_znak # Replace with your PyPI project name 39 | permissions: 40 | id-token: write # IMPORTANT: mandatory for trusted publishing 41 | steps: 42 | - name: Download all the dists 43 | uses: actions/download-artifact@v3 44 | with: 45 | name: python-package-distributions 46 | path: dist/ 47 | - name: Publish distribution 📦 to PyPI 48 | uses: pypa/gh-action-pypi-publish@release/v1 49 | publish-to-testpypi: 50 | name: Publish Python 🐍 distribution 📦 to TestPyPI 51 | if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes 52 | needs: 53 | - build 54 | runs-on: ubuntu-latest 55 | 56 | environment: 57 | name: testpypi 58 | url: https://test.pypi.org/p/nechestniy_znak 59 | 60 | permissions: 61 | id-token: write # IMPORTANT: mandatory for trusted publishing 62 | 63 | steps: 64 | - name: Download all the dists 65 | uses: actions/download-artifact@v3 66 | with: 67 | name: python-package-distributions 68 | path: dist/ 69 | - name: Publish distribution 📦 to TestPyPI 70 | uses: pypa/gh-action-pypi-publish@release/v1 71 | with: 72 | repository-url: https://test.pypi.org/legacy/ 73 | --------------------------------------------------------------------------------