initial commit
This commit is contained in:
0
scanner/__init__.py
Normal file
0
scanner/__init__.py
Normal file
13
scanner/enums.py
Normal file
13
scanner/enums.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from enum import unique, IntEnum
|
||||
|
||||
|
||||
@unique
|
||||
class CodeType(IntEnum):
|
||||
BARCODE = 0
|
||||
QRCODE = 1
|
||||
INVALID = 2
|
||||
|
||||
|
||||
@unique
|
||||
class SearchType(IntEnum):
|
||||
PRODUCT = 0
|
||||
11
scanner/search.py
Normal file
11
scanner/search.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from scanner.enums import CodeType
|
||||
from scanner.utils import guess_code_type
|
||||
|
||||
|
||||
class ScannerSearch:
|
||||
def __init__(self, string_value: str):
|
||||
self.string_value = string_value
|
||||
self._code_type = guess_code_type(self.string_value)
|
||||
|
||||
def get_code_type(self) -> CodeType:
|
||||
return self._code_type
|
||||
9
scanner/utils.py
Normal file
9
scanner/utils.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from scanner.enums import CodeType
|
||||
|
||||
|
||||
def guess_code_type(string_value: str) -> CodeType:
|
||||
if string_value.isdigit():
|
||||
return CodeType.BARCODE
|
||||
if string_value:
|
||||
return CodeType.QRCODE
|
||||
return CodeType.INVALID
|
||||
Reference in New Issue
Block a user