
    Zic                         S r SSKrSSKrSSKrSSKrSSKJr  SSKrSSKJ	r	  SSK
JrJr   " S S\R                  5      r " S	 S
\R                  5      rS rS rg)z0
Use argparse to handle command-line arguments.
    N)Path   )VERSION)DEFAULT_ENCODING_get_available_extensionsc                   "    \ rS rSrSrSS jrSrg)AddToNamespaceAction   zDThis adds KEY,VALUE arbitrary pairs to the argparse.Namespace objectNc                     [        U[        5      (       d   eUR                  5       R                  S5      u  pV[	        X%5      (       a  UR                  S[        5       -  5        [        X%U5        g )N=z;Duplicate specification of the key "%(key)s" with --option.)
isinstancestrstripsplithasattrerrorlocalssetattr)selfparser	namespacevaluesoption_stringkeyvals          f/var/www/eduai.edurigo.com/question_generate/ques_gen_env/lib/python3.13/site-packages/textract/cli.py__call__AddToNamespaceAction.__call__   s]    &#&&&&<<>'',9""LLN( 		$     N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r    r   r   r	   r	      s
    N%r   r	   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )FileType    c                 V  > US:X  a  SU R                   ;   a:  SU R                   ;   a  [        R                  R                  $ [        R                  $ SU R                   ;   a:  SU R                   ;   a  [        R                  R                  $ [        R                  $ [
        TU ]  U5      $ )N-rbw)_modesysstdinbufferstdoutsuperr   )r   string	__class__s     r   r   FileType.__call__!   sz    S=djj +.$**+<syy''K#))Kdjj ,/4::,=szz((M3::Mw''r   r    )r"   r#   r$   r%   r   r'   __classcell__)r7   s   @r   r)   r)       s    ( (r   r)   c            	         [         R                  " SS9n U R                  SSS9n[        R                  R
                  Ul        U R                  SS[        [        [        5       SS	9  U R                  S
[        S[        5       SS	9  U R                  SSSSS9  U R                  SS[        S5      SSS9  U R                  SS[        [        SS9  U R                  SSSS[        -   S 9  [        R                  " U 5        U $ )!z^Initialize the parser for the command line interface and bind the
autocompletion functionalityz8Command 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choicesr=   z--extensionNz"Specify the extension of the file.z-mz--method z:Specify a method of extraction for formats that support it)r?   r=   z-oz--outputwbr,   zOutput raw text in this file)r>   r?   r=   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)r>   actionr=   z-vz	--versionversionz	%(prog)s )rC   rD   )argparseArgumentParseradd_argumentargcomplete
completersFilesCompleter	completerr   r   _get_available_encodingsr   r)   r	   r   autocomplete)r   filename_actions     r   
get_parserrO   ,   sC   
 $$NF
 ))( * O !, 6 6 E EO
 (*2   )+1   I	   d^+   #:  
 g%	   V$Mr   c                  L   [        [        R                  R                  R                  5       5      n [	        [        [        R                  5      R                  5      /nU R                  S [        R                  " US9 5       5        [        U 5      n U R                  5         U $ )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
c              3   *   #    U  H	  u  po2v   M     g 7fr!   r    ).0importermodnameispkgs       r   	<genexpr>+_get_available_encodings.<locals>.<genexpr>w   s      0Q,Hu0Qs   )path)set	encodingsaliasesr   r   r   __file__parentupdatepkgutilwalk_packageslistsort)available_encodingspathss     r   rL   rL   o   s     i//77>>@Ai(()0012E 070E0E50Q  23r   )r&   rE   rZ   r_   r1   pathlibr   rH   rA   r   parsersr   r   Actionr	   r)   rO   rL   r    r   r   <module>rh      sR       
    @%8?? %(x   (@Fr   