-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
78 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
<img src="https://habrastorage.org/webt/7w/rw/6w/7wrw6w-k_woryibchbnbpezesag.jpeg"> | ||
<p align="center"> | ||
<img src="https://habrastorage.org/webt/7w/rw/6w/7wrw6w-k_woryibchbnbpezesag.jpeg"> | ||
</p> | ||
<p align="center"> | ||
<img src="https://img.shields.io/pypi/v/nechestniy_znak.svg"> <img src="https://img.shields.io/pypi/pyversions/nechestniy_znak.svg"> | ||
</p> | ||
|
||
[Github](https://github.com/li0ard/nechestniy_znak) | ||
Библеотека обертка для API ГИС МТ "Честный Знак" и API ЕГАИС | ||
|
||
[Документация](https://li0ard.gitbook.io/nechestniy_znak/) | ||
|
||
Библеотека обертка для API ГИС МТ "Честный Знак" | ||
### Установка | ||
|
||
**Требуется Python версии 3.8 или выше** | ||
``` | ||
pip install nechestniy_znak | ||
``` | ||
|
||
### Пример | ||
```py | ||
from nechestniy_znak import Lib | ||
from nechestniy_znak import Crpt, Egais | ||
|
||
crpt = Crpt() | ||
print(crpt.infoFromEAN13(46494139)) | ||
print(crpt.infoFromDataMatrix("00000046209849Uon<TYfACyAJPHJ")) | ||
print(crpt.infoFromQr("chek.markirovka.nalog.ru/kc/?kiz=RU-430302-AAA4050108")) | ||
print(crpt.infoFromReceipt("t=20231203T2319&s=261.80&fn=7281440701309134&i=10027&fp=3516337491&n=1")) | ||
|
||
lib = Lib() | ||
print(lib.infoFromEAN13(46494139)) | ||
print(lib.infoFromDataMatrix("00000046209849Uon<TYfACyAJPHJ")) | ||
print(lib.infoFromQr("chek.markirovka.nalog.ru/kc/?kiz=RU-430302-AAA4050108")) | ||
print(lib.infoFromReceipt("t=20231203T2319&s=261.80&fn=7281440701309134&i=10027&fp=3516337491&n=1")) | ||
egais = Egais() | ||
print(egais.getInfoByMarkOld("22N00001543ZQO6QFMW37ZK80215021095854A4P1E4IHMW86GT5RTFHN5XXFABT9TZ9", "104-101355000854071217387105240265")) | ||
print(egais.getInfoByMarkNew("171200031066131018001EWB6ECS6IGT6L2OH7XP6QFJMTYQMXCZ5WWVPNDLUU7BCE4FWLCBM7QDHQSESJCTOIXMEAHE2EZLXRZXJJT4UJ4OKEFEIO7RE7J7LQK2ISDFXIA34UAYOZ5ZRYFLTXI4TQ")) | ||
print(egais.getInfoByAlcCode("0150320000003561384")) | ||
print(egais.getChains("171200031066131018001EWB6ECS6IGT6L2OH7XP6QFJMTYQMXCZ5WWVPNDLUU7BCE4FWLCBM7QDHQSESJCTOIXMEAHE2EZLXRZXJJT4UJ4OKEFEIO7RE7J7LQK2ISDFXIA34UAYOZ5ZRYFLTXI4TQ")) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "nechestniy_znak" | ||
version = "1.0.1" | ||
version = "1.0.2" | ||
authors = [ | ||
{ name="li0ard", email="[email protected]" }, | ||
] | ||
|
@@ -16,7 +16,7 @@ readme = "README.md" | |
requires-python = ">=3.8" | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
] | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
from .lib import * | ||
from .crpt import * | ||
from .egais import * | ||
|
||
__version__ = "1.0.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
from typing import Union | ||
|
||
|
||
class Lib: | ||
class Crpt: | ||
def __init__(self): | ||
pass | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import requests, urllib3 | ||
from typing import Union | ||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||
|
||
class Egais: | ||
def __init__(self): | ||
pass | ||
|
||
def _get(self, url: str, params: str) -> Union[list, dict]: | ||
return requests.get(f"http://mobapi.fsrar.ru/api3/{url}?{params}", verify=False).json() | ||
|
||
def getInfoByMarkOld(self, pdf417: str, datamatrix: str) -> Union[list, dict]: | ||
return self._get("mark", f"DataMatrix={datamatrix}&Pdf417={pdf417}") | ||
|
||
def getInfoByMarkNew(self, datamatrix: str) -> Union[list, dict]: | ||
return self._get("marklong", f"Pdf417={datamatrix}") | ||
|
||
def getInfoByAlcCode(self, alc_code: str) -> Union[list, dict]: | ||
return self._get("product_info", f"alc_code={alc_code}") | ||
|
||
def getChains(self, datamatrix: str) -> Union[list, dict]: | ||
return self._get("chain", f"barcode={datamatrix}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
from nechestniy_znak import Lib | ||
import pytest | ||
from src.nechestniy_znak import Crpt, Egais | ||
|
||
lib = Lib() | ||
print(lib.infoFromEAN13(46494139)) | ||
print(lib.infoFromDataMatrix("00000046209849Uon<TYfACyAJPHJ")) | ||
print(lib.infoFromQr("chek.markirovka.nalog.ru/kc/?kiz=RU-430302-AAA4050108")) | ||
print(lib.infoFromReceipt("t=20231203T2319&s=261.80&fn=7281440701309134&i=10027&fp=3516337491&n=1")) | ||
crpt = Crpt() | ||
|
||
def test_crptEAN13(): | ||
assert crpt.infoFromEAN13(46494139)["checkResult"] == True | ||
|
||
def test_crptDataMatrix(): | ||
assert crpt.infoFromDataMatrix("00000046209849Uon<TYfACyAJPHJ")["checkResult"] == True | ||
|
||
def test_crptQR(): | ||
assert crpt.infoFromQr("chek.markirovka.nalog.ru/kc/?kiz=RU-430302-AAA4050108")["checkResult"] == True | ||
|
||
def test_crptReceipt(): | ||
assert crpt.infoFromReceipt("t=20231203T2319&s=261.80&fn=7281440701309134&i=10027&fp=3516337491&n=1")["checkResult"] == True | ||
|
||
egais = Egais() | ||
|
||
def test_egaisMarkOld(): | ||
assert egais.getInfoByMarkOld("22N00001543ZQO6QFMW37ZK80215021095854A4P1E4IHMW86GT5RTFHN5XXFABT9TZ9", "104-101355000854071217387105240265")["success"] == True | ||
|
||
def test_egaisMarkNew(): | ||
assert egais.getInfoByMarkNew("171200031066131018001EWB6ECS6IGT6L2OH7XP6QFJMTYQMXCZ5WWVPNDLUU7BCE4FWLCBM7QDHQSESJCTOIXMEAHE2EZLXRZXJJT4UJ4OKEFEIO7RE7J7LQK2ISDFXIA34UAYOZ5ZRYFLTXI4TQ")["success"] == True | ||
|
||
def test_egaisChains(): | ||
assert egais.getChains("171200031066131018001EWB6ECS6IGT6L2OH7XP6QFJMTYQMXCZ5WWVPNDLUU7BCE4FWLCBM7QDHQSESJCTOIXMEAHE2EZLXRZXJJT4UJ4OKEFEIO7RE7J7LQK2ISDFXIA34UAYOZ5ZRYFLTXI4TQ")["success"] == True |
Empty file.