refine type checking
This commit is contained in:
parent
aae551b4ce
commit
e0320f8f68
@ -462,7 +462,7 @@ class Escpos(object):
|
|||||||
align_ct: bool = True,
|
align_ct: bool = True,
|
||||||
function_type=None,
|
function_type=None,
|
||||||
check: bool = True,
|
check: bool = True,
|
||||||
force_software: bool = False,
|
force_software: Union[bool, str] = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Print barcode.
|
"""Print barcode.
|
||||||
|
|
||||||
@ -546,9 +546,11 @@ class Escpos(object):
|
|||||||
raise BarcodeTypeError(f"Not supported or wrong barcode name {bc}.")
|
raise BarcodeTypeError(f"Not supported or wrong barcode name {bc}.")
|
||||||
|
|
||||||
if force_software or not capable["hw"] or not capable_bc["hw"]:
|
if force_software or not capable["hw"] or not capable_bc["hw"]:
|
||||||
|
# based on earlier checks, we require that software mode is not None
|
||||||
|
assert capable["sw"] is not None
|
||||||
# Select the best possible capable render mode
|
# Select the best possible capable render mode
|
||||||
impl = capable["sw"][0]
|
impl = capable["sw"][0]
|
||||||
if force_software in capable["sw"]:
|
if force_software in capable["sw"] and isinstance(force_software, str):
|
||||||
# Force to a specific mode
|
# Force to a specific mode
|
||||||
impl = force_software
|
impl = force_software
|
||||||
print(f"Using {impl} software barcode renderer")
|
print(f"Using {impl} software barcode renderer")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user