
    njw                        S SK r S SKrS SKrS SKJr  S SKJrJrJr  S SK	r	S SK
Jr   SS\\   S\4S jjrS\\   4S	 jr SS
\\   S\\   4S jjr\R                   4S jr\S:X  a#  \R&                  " \" \R                   5      5        gg)    N)Path)ListOptionalSequence)PathLikeOrStrfilename_listbatch_contentc                 h    U  H  n[        U5      R                  S5      n[        R                  R	                  U5      (       d  MC  UR                  S5      n[        SU S35        [        US5       nUR                  U5        SSS5        M     g! , (       d  f       M  = f! [         a     gf = f)	a`  
:param filename_list: list of file names (full path)
:param batch_content: contents of the wrapper batch file
:return: 0 if succeeded, 1 otherwise
The function create a wrapper batch file for each existing python file for invoking as a script
It is useful on Windows if the file association of *.py files is not python.exe (but some IDE for instance)
z.pyz.batz
Creating: z...wNr      )	r   with_suffixospathexistsprintopenwrite	Exception)r   r	   script_namepy_name
batch_namefiles         _/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/osgeo_utils/auxiliary/batch_creator.pybatch_creatorr   )   s    
(K;'33E:Gww~~g&&$008

:,c23*c*dJJ}- +* )  +*  s0   AB$ ,B$ 3BB$ 
B!	B$ $
B10B1returnc                     / n[         R                  " U R                  5       H  nUu  p4nUR                  U5        M     U$ )N)pkgutilwalk_packages__path__append)modulesub_modules
sub_module_sub_module_names        r   get_sub_modulesr&   A   s@    K++FOO<
 *A?+ =     script_namesrootc                     Uc)  [        [        R                  5      R                  S   S-  nU c  [	        [
        5      n U  Vs/ s H$  n[        U5      [        U5      R                  -  PM&     nn[        U5      $ s  snf )Nr   Scripts)r   sys
executableparentsr&   osgeo_utilsnamer   )r(   r)   sscriptss       r   batch_creator_by_modulesr3   I   sm     |CNN#++A.:&{32>?,QtDzDGLL(,G?!! @s   +A;c                 D    [        U 5      S::  a  S OU SS  n[        U5      $ )Nr   )lenr3   )argvscripts_lists     r   mainr8   T   s$    t9>4tABxL#L11r'   __main__)z@python "%~dp0\%~n0.py" %*)NN)r   r   r,   pathlibr   typingr   r   r   r/   osgeo_utils.auxiliary.baser   strr   r&   r3   r6   r8   __name__exit r'   r   <module>rA      s   > 
  
  + +  4
 7M*0tCy  IM"3-".6}.E" hh 2
 zHHT#((^ r'   