o
    tBhs                     @   s   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 zd dl	m
Z
 W n ey3   dZ
Y nw dZ
dZddd	Zdd
dZdd Zdd ZedkrSe  dS dS )    N)ArgumentParser)version)ImageWriter)	SVGWriter)QtCore)BMPGIFJPEGMSPPCXPNGTIFFXBMc                 C   s   d S N argsparserr   r   h/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/barcode/pybarcode.pyopen_gui   s   r   c                 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_FORMATSr   r   r   r   
list_types   s   r   c                 C   s   | j  | _ | j dkr| j tvr|dj| j d | j | _| jtjvr0|dj| jd | j dkr>d| j i}t }nd| j	i}t
 }tjtj| j}t| j| j|||| j}td| d S )	NSVGz9Unknown type {type}. Try list action for available types.)typez=Unknown barcode {bc}. Try list action for available barcodes.)bcformatcompresszNew barcode saved as {}.)r   upperr   errorr    r   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   sv  g } t d u r| d n| d 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rs|jd d!d"d |jd#d$d}|j	t
d% td ur|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$PyQt not found, gui action disabled.z/PyQt found. Use gui action to get a simple GUI.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guiz+Opens a simple PyQt GUI to create barcodes.svgFcode39)r   r!   r<   r   r,   zYou need to tell me what to do.)r   appendr   r   r   add_argumentr   add_subparsers
add_parserset_defaultsr   r   r1   
parse_argsr<   AttributeErrorr#   )msgr   
subparserscreate_parserlist_parser
gui_parserr   r<   r   r   r   main?   sp   



rL   __main__r   )r%   argparser   r   barcode.versionr   barcode.writerr   r   PyQt4r   ImportErrorr   r   r   r1   rL   __name__r   r   r   r   <module>   s(    

>
