o
    fin                     @  s   d dl mZ d dlZd dlmZ d dlZd dlmZ d dlm	Z	 d dlm
Z
 d dlmZ dZddddZdddZdddZedkrGe  dS dS )    )annotationsN)ArgumentParser)version)
BaseWriter)ImageWriter)	SVGWriter)BMPGIFJPEGMSPPCXPNGTIFFXBMreturnNonec                 C  s^   t d t dtj t d t d t d td ur%t ddt nt d t d d S )Nz*
python-barcode available barcode formats:z, 
zAvailable image formatszStandard: svgzPillow:zPillow: disabled)printjoinbarcodePROVIDED_BARCODESr   IMG_FORMATS)argsparser r   E/home/ubuntu/.local/lib/python3.10/site-packages/barcode/pybarcode.py
list_types   s   r   c                 C  s   | j  | _ | j dkr| j tvr|d| j  d | j | _| jtjvr0|d| j d | j dkrDtd us;J d| j i}t }nd| ji}t	 }t
jt
j| j}t| j| j|||| j}td| d	 d S )
NSVGzUnknown type z&. Try list action for available types.zUnknown barcode z). Try list action for available barcodes.formatcompresszNew barcode saved as .)typeupperr   errorr   lowerr   r   r   r   ospathnormpathabspathoutputgeneratecodetextr   )r   r   optswriteroutnamer   r   r   create_barcode   s"   


r1   c                  C  s6  g } t d u r| d n| d tdd| d}|jdddd	t d
 |jdd}|jddd}|jddd |jddd |jddddd |jdddd |jddd t d urd|jddd d |jd!d"d}|jt	d# |jd$d%t
d&d d' | }z|j}W n ty   |d( Y d S w ||| d S ))NzAImage output disabled (Pillow not found), --type option disabled.zNImage output enabled, use --type option to give image format (png, jpeg, ...).z!Create standard barcodes via cli. )descriptionepilogz-vz	--versionr   z	%(prog)s )actionr   Actions)titlecreatez(Create a barcode with the given options.)helpr+   zCode to render as barcode.r)   z7Filename for output without extension, e. g. mybarcode.z-cz
--compress
store_truez0Compress output, only recognized if type is svg.)r5   r9   z-bz	--barcodez&Barcode to use [default: %(default)s].z--textzText to show under the barcode.z-tz--typez&Type of output [default: %(default)s].listz$List available image and code types.)funcsvgFcode39)r!   r   r<   r   r,   zYou need to tell me what to do.)r   appendr   r   add_argumentr   add_subparsers
add_parserset_defaultsr   r1   
parse_argsr<   AttributeErrorr#   )msgr   
subparserscreate_parserlist_parserr   r<   r   r   r   main1   s`   


rJ   __main__)N)r   r   )
__future__r   r%   argparser   r   barcode.versionr   barcode.writerr   r   r   r   r   r1   rJ   __name__r   r   r   r   <module>   s    

5
