
    Sh                        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 n# e	$ r	 d dl
mZ Y nw xY wej                            ej        d                                        ddd          Z eej        dej                  Z eej        dej                  ZeedZ	 eZn# e$ r Y nw xY w ej        e          Zd Zd	 Z	 	 	 	 	 ddZd ZddZ ddZ!dS )    N)MutableSequence-    bufferinputoutputc                     | S )zf
    Used when we didn't explicitly specify a stream to avoid using
    codecs.get{reader,writer}
     )streams    U/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/srt_tools/utils.pynoopr      s	    
 M    c                 ,    | dk    rt           |         S | S )Nr   )DASH_STREAM_MAP)argarg_types     r   dash_to_streamr   '   s    
czzx((Jr   Fc           	         g }||                     d           |                                D ]U\  }}|                     d                    |                     |                     d                    |                     Vt          j        t
          | d                    |          t          j                  }|r|                    dddd	d
 dd           n!|                    dddt          d d           |s<|                    dddt          d d           |s|                    dddd           d}	|rt          j        }	|                    ddd|	           |                    dd d!t          j        t          j        d"#           |                    d$d%dd&           |                    d'd(d)*           |S )+Nz	examples:z  {}z	    $ {}

)progdescriptionepilogformatter_classz--inputz-iFILEappendc                 "    t          | d          S Nr	   r   r   s    r   <lambda>zbasic_parser.<locals>.<lambda>M       ^C99 r   zthe files to processT)metavaractiontypehelprequiredc                 "    t          | d          S r   r    r!   s    r   r"   zbasic_parser.<locals>.<lambda>W   r#   r   z$the file to process (default: stdin))r$   defaultr&   r'   z--outputz-oc                 "    t          | d          S )Nr
   r    r!   s    r   r"   zbasic_parser.<locals>.<lambda>a   s    ^C:: r   z&the file to write to (default: stdout)z	--inplacez-p
store_truezmodify file in place)r%   r'   z:allow blank lines in output, your media player may explodez--no-strictstore_falsestrict)r%   destr'   z--debugstore_const	log_levelzenable debug logging)r%   r/   constr*   r'   z--ignore-parsing-errorsz-cz3try to keep going, even if there are parsing errorsz
--encodingz-ez3the encoding to read/write files in (default: utf8))r'   )r   itemsformatargparseArgumentParser	PROG_NAMEjoinRawDescriptionHelpFormatteradd_argumentSTDIN_BYTESTREAMSTDOUT_BYTESTREAMSUPPRESSloggingDEBUGINFO)
r   multi_input	no_outputexampleshide_no_strictexample_linesdesccodeparsershelps
             r   basic_parserrJ   -   s`    M[)))"..** 	< 	<JD$  t!4!4555  !4!4T!:!:;;;;$yy'' <	  F  
99' 	 	
 	
 	
 	
 	$997 	 	
 	
 	
  %::9 	 	
 	
 	
  	#+	      IE "!
m(QVWWW
m#     !B	     d!V     Mr   c                    t          | dd           rV| j        t          d         k    rt          d          | j        t          d         k    rt          d          | j        | _        dD ]}t
                              d|           	 t          | |          }n# t          $ r Y <w xY w| j        pd}| j        pd	}t          j
        |          }t          j        |          }t
                              d
|           |t                                          v rt
                              d|           || j        u rBt          j         || j                                                  | j                  | _        || j        u r || j                  | _        6t
                              d|           || j        u rht#          | j        t$                    rt'          | j                  D ]\  }}|t                                          v rH|| j        u r>t          j         ||                                          | j                  | j        |<   h |t)          |d                    }	|	5  t          j        |	                                | j                  | j        |<   d d d            n# 1 swxY w Y   ѐ\ |t)          |d                    }	|	5  t          j        |	                                | j                  | _        d d d            n# 1 swxY w Y    |t)          | j        d                    | _        d S )Ninplacer	   zCannot use --inplace on stdinr
   zCannot use -o and -p togetherr   zProcessing stream "%s"z	utf-8-sigzutf-8zGot %r as streamz%s in DASH_STREAM_MAP)ignore_errorsz%s not in DASH_STREAM_MAPrbwb)getattrr	   r   
ValueErrorr
   logdebugAttributeErrorencodingcodecs	getreader	getwritervaluessrtparsereadignore_parsing_errors
isinstancer   	enumerateopen)
argsstream_namer   read_encodingwrite_encodingr_encw_enciinput_fnfs
             r   set_basic_argsrj      s   tY%% !:111<===;/(333<===j* 9= 9=		*K888	T;//FF 	 	 	H	 41' // 00		$f--- _++----II-{;;;## YE$*%%**,,D<V  

 4;&& $eDK00II1;???##dj/:: '0'<'< " "8#'='='?'???%3303	$)E(OO$8$8$:$:262L1" 1" 1"
1
 !&d8T&:&: ; ;A!" " "03	$%FFHHD<V1" 1" 1"
1" " " " " " " " " " " " " " "" d640011A  %(YFFHHD4N& & &
              
 $eDd$;$;<<s9= 9=s6   	B
B'&B'66J88J<?J<!3L  L$	'L$	Tc                     	 t          j        | |t          j        d          S # t           j        $ r }t
                              d            d }~ww xY w)NT)r.   eolin_placezLParsing failed, maybe you need to pass a different encoding with --encoding?)rZ   composeoslinesepSRTParseErrorrR   critical)subsr.   
thrown_excs      r   compose_suggest_on_failru      sd    {4BJNNNN   	
 	
 	
 	s   !$ AAA   c              #   :  K   t          |           }t          t          j        ||                    }|st	          |          |k    rdS |V  |D ]}|dd         |fz   }|V  |r1t          t	          |                    D ]}|dk    r||d         V  dS dS )z]
    If inclusive is True, we also include final elements where len(sliced) <
    width.
    Nr   r   )itertuple	itertoolsislicelenrange)seqwidth	inclusiveseq_iterslicedelemidxs          r   sliding_windowr      s      
 CyyH 9#He4455F V--
LLL  tg% #V%% 	# 	#CaxxSTTl"""# #	# 	#r   )NFFNF)T)rv   T)"r5   rV   rZ   r>   sysrz   ro   collections.abcr   ImportErrorcollectionspathbasenameargvreplacer7   rP   stdinr;   stdoutr<   r   xranger}   	NameError	getLogger__name__rR   r   r   rJ   rj   ru   r   r   r   r   <module>r      s     



  



     				,/////// , , ,++++++++, GSXa[))11#sA>>	739h	:: GCJ#*== ,8IJJ	EE 	 	 	D	 g!!     W W W WtD= D= D=N	 	 	 	# # # # # #s   % 33$B' 'B/.B/