From 746a65a8304e54115662e6610a1bf9bc68da076f Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Thu, 7 Apr 2022 00:26:32 +0300 Subject: [PATCH 1/6] =?UTF-8?q?=E2=9A=99:=20Update=20requirements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 44876bb..e9a9605 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,11 @@ -decorator==5.1.0 -Pillow==9.0.1 -pydantic==1.8.2 -pyzbar==0.1.8 +decorator==5.1.1 +numpy==1.21.5 +opencv-python==4.5.5.64 +Pillow==9.1.0 +pkg_resources==0.0.0 +pydantic==1.9.0 qrcode==7.3.1 six==1.16.0 -typing-extensions==3.10.0.2 +typing_extensions==4.1.1 uttlv==0.6.0 validators==0.18.2 From 909b510f817d4104c613e131bf135ec64e37d8a3 Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Thu, 7 Apr 2022 00:31:48 +0300 Subject: [PATCH 2/6] =?UTF-8?q?=E2=9A=99:=20Remove=20`zbar`=20from=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/python-app.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 7ae0229..9d85399 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -26,7 +26,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - sudo apt-get install zbar-tools python3 -m pip install --upgrade pip python3 -m pip install -r requirements.txt - name: Test with pytest From 441169de81d07a4169842fe4183d39a316ffd0f2 Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Thu, 7 Apr 2022 00:32:23 +0300 Subject: [PATCH 3/6] =?UTF-8?q?=E2=9C=8D:=20Update=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 4260564..0d58bc2 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,6 @@ ## Requirements * [Python](https://Python.org/) >= 3.8 -* [zbar-tools](http://zbar.sourceforge.net/) ## Installation From 8a5625f7b5c76f0803ba8a51cd01c313fd227b8b Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Thu, 7 Apr 2022 00:36:01 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=E2=9C=A8:=20Unused=20`zbar`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fatoora/fatoora.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/fatoora/fatoora.py b/fatoora/fatoora.py index 13dfdf3..3b583eb 100644 --- a/fatoora/fatoora.py +++ b/fatoora/fatoora.py @@ -11,7 +11,7 @@ import json from typing import Union, Optional from PIL import Image -from pyzbar.pyzbar import decode +import cv2 from pydantic import validate_arguments import validators from datetime import datetime @@ -21,6 +21,31 @@ iso8601_zulu_format = "%Y-%m-%dT%H:%M:%SZ" +def _decode(filename: str) -> str: + """Returns the date of qrcode + + Args: + filename (str): qrcode you want to get the date of it + + Exception: + Exception: Invalid qrcode + + Returns: + str: date of qrcodee + """ + image = cv2.imread(filename) + # initialize the cv2 QRCode detector + detector = cv2.QRCodeDetector() + # detect and decode + data, vertices_array, _ = detector.detectAndDecode(image) + # if there is a QR code + # print the data + if vertices_array is not None: + return data + else: + raise Exception("Invalid qrcode") + + def is_valid_iso8601_zulu_format(string_date: str) -> bool: """Returns True if the string valid ISO 8601 Zulu format @@ -96,7 +121,7 @@ def read_qrcode(cls, filename: str, dct: bool = False) -> Union[str, dict]: Returns: Union[str, dict]: content of qr code """ - data = decode(Image.open(filename))[0].data.decode() + data = _decode(filename) if dct: return cls.base2dict(data) From 718b7242245ae24145d6f3bb4b1845dc3b51e76b Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Thu, 7 Apr 2022 00:38:11 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=9A=80:=20Update=20version=20to=20`v3?= =?UTF-8?q?.0.0`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fatoora/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fatoora/version.py b/fatoora/version.py index 0476bb0..779eb3d 100644 --- a/fatoora/version.py +++ b/fatoora/version.py @@ -1,6 +1,6 @@ __all__ = "version", "version_info" -version = "2.1.3" +version = "3.0.0" def version_info() -> str: From c0cdcb2fc2d338067edcd3cc53a06c6f78f1b24a Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Thu, 7 Apr 2022 00:45:57 +0300 Subject: [PATCH 6/6] =?UTF-8?q?=E2=9A=99:=20Remove=20`pkg-resources`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e9a9605..061dd40 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ decorator==5.1.1 numpy==1.21.5 opencv-python==4.5.5.64 Pillow==9.1.0 -pkg_resources==0.0.0 pydantic==1.9.0 qrcode==7.3.1 six==1.16.0