
    ,h[                         d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZmZ  G d dej                        Z G d d	ej"                        Zd
 Zd Zy)z0
Use argparse to handle command-line arguments.
    N   )VERSION)DEFAULT_ENCODING_get_available_extensionsc                       e Zd ZdZddZy)AddToNamespaceActionzIThis adds KEY,VALUE arbitrary pairs to the argparse.Namespace object
    Nc                     |j                         j                  d      \  }}t        ||      r|j                  dt	               z         t        |||       y )N=z;Duplicate specification of the key "%(key)s" with --option.)stripsplithasattrerrorlocalssetattr)selfparser	namespacevaluesoption_stringkeyvals          N/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/textract/cli.py__call__zAddToNamespaceAction.__call__   sM    <<>'',S9c"LLM  		3$    )N)__name__
__module____qualname____doc__r    r   r   r   r      s    %r   r   c                        e Zd Z fdZ xZS )FileTypec                    |dk(  rit         j                  rYd| j                  v rt        j                  j                         }n,d| j                  v rt        j                  j                         }t        t        | '  |      S )N-rw)
sixPY3_modesysstdinfilenostdoutsuperr!   r   )r   string	__class__s     r   r   zFileType.__call__"   s^    S=SWWdjj ))+

"**,Xt-f55r   )r   r   r   r   __classcell__)r/   s   @r   r!   r!   !   s    6 6r   r!   c                  @   t        j                  dt               z        } t        j                  j
                  | j                  dd      _        | j                  ddt        t        t               d	       | j                  d
t        dt               d	       | j                  dddd       | j                  ddt        d      dd       | j                  ddt        t        d       | j                  ddddt        z           t        j                  |        | S )!zbInitialize the parser for the command line interface and bind the
    autocompletion functionalityz9Command line tool for extracting text from any document. )descriptionfilenamezFilename to extract text.)helpz-ez
--encodingz#Specify the encoding of the output.)typedefaultchoicesr4   z--extensionNz"Specify the extension of the file.z-mz--method z:Specify a method of extraction for formats that support it)r6   r4   z-oz--outputwbr#   zOutput raw text in this file)r5   r6   r4   z-Oz--optionzAdd arbitrary options to various parsers of the form KEYWORD=VALUE. A full list of available KEYWORD options is available at http://bit.ly/textract-options)r5   actionr4   z-vz	--versionversionz	%(prog)s )r:   r;   )argparseArgumentParserr   argcomplete
completersFilesCompleteradd_argument	completerstrr   _get_available_encodingsr   r!   r   r   autocomplete)r   s    r   
get_parserrF   -   s;   
 $$GHF ((77 4  
l.>(*2  
 C)+1  
 j"I   jx~s+   js+?:   k)[5H  
 V$Mr   c                  Z   t        t        j                  j                  j                               } t        j
                  j                  t        j                        g}t        j                  |      D ]  \  }}}| j                  |        t        |       } | j                          | S )zGet a list of the available encodings to make it easy to
    tab-complete the command line interface.

    Inspiration from http://stackoverflow.com/a/3824405/564709
    )path)set	encodingsaliasesr   osrH   dirname__file__pkgutilwalk_packagesaddlistsort)available_encodingspathsimportermodnameispkgs        r   rD   rD   `   s     i//77>>@AWW__Y//01E$+$9$9u$E ) '5()23r   )r   r<   rJ   rL   rO   r)   r&   reglobr>   r8   r   parsersr   r   Actionr   r!   rF   rD   r   r   r   <module>r]      sZ      	  
 
 	    @	%8?? 	%6x   60fr   