
    Sh                     &    d dl Z d dlZddZddZdS )    NFc                    d|vsJ t          j        |           D ],\  }}}|D ]!}|                    d          rt           j                            ||          }|rt          d|            t          |          5 }	|	                                }
ddd           n# 1 swxY w Y   |
                    d          }d}g }|D ])}|	                                
                    d          s'|	                                                    d          r |                    d          d	z  d
k    r| }n|s|	                                d| k    r#|                    d| d| d| d|           }nc|                    d| dd| d| d          }|                    d| dd| d| d          }|                    d| dd| d| d          }|                    |           +t          |d          5 }	|	                    d                    |          dz              ddd           n# 1 swxY w Y   #.dS )a  Rewrite internal package imports for move to a `src/` dir structure.

    If your project has its code in `package_name/`, and you want to instead
    move that code to `package_name/src/`, this script will change all lines
    of the form e.g.

    `from package_name.x.y import z` to `from package_name.src.x.y import z`

    if you call it as

    `rewrite_python_file_imports("package_name/", "package_name", "src")`
    .z.pyz...processing N
Fz""""      zimport z as zfrom z importw)oswalkendswithpathjoinprintopenreadsplitstrip
startswithcountreplaceappendwrite)
target_dir	root_nameoffset_nameverboseroot_filesfnamefpathfcontentslines	in_string	new_lineslines                  S/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/namex/convert.pyrewrite_python_file_importsr)      s6    k!!!!'*-- &9 &9a %	9 %	9E~~e$$ $9T511 42522333%[[ (A vvxxH( ( ( ( ( ( ( ( ( ( ( ( ( ( ( t,,!		! + +Dzz||..u55 "9N9Nu9U9U "::c??Q.!33,5I( "#zz||/D/D/DDD'+||$9i$9$9$Vi$V$V+$V$V9$V$V(" ("
 (,||$:i$:$:$:$Hi$H$H+$H$H$H(" (" (,||$8I$8$8$8:\):\:\k:\:\:\(" (" (,||$>I$>$>$>$LI$L$L$L$L$L(" (" $$T****%%% 9GGDIIi00478889 9 9 9 9 9 9 9 9 9 9 9 9 9 9I%	9&9 &9s$    B!!B%(B%,H::H>H>srcc                    t           j                            |           st          d|  d          t          j        | |           t          j        |            t          j        |t           j                            | |                     t          | | dd           t          t           j                            | d          d          5  	 d d d            d S # 1 swxY w Y   d S )NzNo directory named 'z'.r*   T)r   r   r   r   z__init__.pyr	   )r
   r   exists
ValueErrorrenamemkdirshutilmover   r)   r   )packagecode_directorys     r(   convert_codebaser4   <   s   7>>'"" =;;;;<<<Ig~&&&HW
KWn E EFFFg5$   
 
bgll7M22C	8	8                   s   CC#&C#)F)r*   )r
   r0   r)   r4        r(   <module>r7      sJ    				 49 49 49 49n     r6   