
    c                     H    d Z ddlmZ ddlmZ ddlmZ  G d d          ZdS )a  Fix the name of modules

This module is useful when you want to rename many of the modules in
your project.  That can happen specially when you want to change their
naming style.

For instance::

  fixer = FixModuleNames(project)
  changes = fixer.get_changes(fixer=str.lower)
  project.do(changes)

Here it renames all modules and packages to use lower-cased chars.
You can tell it to use any other style by using the ``fixer``
argument.

    )
taskhandle)changestack)renamec                   F    e Zd Zd Zej        ej        fdZd Z	d Z
d ZdS )FixModuleNamesc                     || _         d S N)project)selfr
   s     8lib/python3.11/site-packages/rope/contrib/fixmodnames.py__init__zFixModuleNames.__init__   s        c                    t          j        | j        d          }|                    d|                     |          dz             }	 	 |                     |          D ]}|                    |j                   t          j	        | j        |          }|
                     ||                     |                              }|                    |           |                                  nn	 |                    d           |                                 |                                 nB# |                    d           |                                 |                                 w xY w|                                S )zFix module names

        `fixer` is a function that takes and returns a `str`.  Given
        the name of a module, it should return the fixed name.

        zFixing module names   TzReverting to original state)r   ChangeStackr
   create_jobset_count_fixes_tobe_fixedstarted_jobpathr   Renameget_changes_namepushfinished_jobpop_allmerged)r   fixertask_handlestackjobsetresourcerenamerchangess           r   r   zFixModuleNames.get_changes   sw    '6KLL**!4#4#4U#;#;a#?
 
	"	 $ 0 0 7 7  H&&x}555$mDL(CCG%11%%

88L8L2M2MNNGJJw''''')))E	 <===MMOOO!!!! <===MMOOO!!!!||~~s   B*D1 1?E0c                 `    t          t          |                     |                              S r	   )lenlistr   )r   r   s     r   r   zFixModuleNames._count_fixes7   s&    4((//00111r   c              #      K   | j                                         D ]*}|                     |          }| ||          k    r|V  +d S r	   )r
   get_python_filesr   )r   r   r"   modnames       r   r   zFixModuleNames._tobe_fixed:   s]      5577 	 	Hjj**G%%..( 	 	r   c                 l    |j                             dd          d         }|dk    r|j        j         }|S )N.r   r   r   )namersplitparent)r   r"   r*   s      r   r   zFixModuleNames._name@   s:    -&&sA..q1j  	+o*Gr   N)__name__
__module____qualname__r   strlowerr   DEFAULT_TASK_HANDLEr   r   r   r    r   r   r   r      sp           !$	z7U    82 2 2      r   r   N)__doc__	rope.baser   rope.contribr   rope.refactorr   r   r6   r   r   <module>r;      sy    " !           $ $ $ $ $ $            - - - - - - - - - -r   