
    c                         d Z ddlZddlZddlZddlmZmZm	Z	 ddZ
d Z e	j                    d             Zd Zd Zej        fd	ZddZddZd Zd ZdS )z2A few useful functions for using rope as a library    N)pyobjectsdef
taskhandleutilsc                 R   t          | |          }|Gt          j        j                            |          }t          j        j                                        } ||                     |          S |dk    r|                     |          S |dk    r|                     |          S dS )aL  Get the resource at path

    You only need to specify `type` if `path` does not exist.  It can
    be either 'file' or 'folder'.  If the type is `None` it is assumed
    that the resource already exists.

    Note that this function uses `Project.get_resource()`,
    `Project.get_file()`, and `Project.get_folder()` methods.

    Nfilefolder)	path_relative_to_project_rootropebaseproject	_realpathget_no_projectget_resourceget_file
get_folder)r   pathtypeproject_paths       2lib/python3.11/site-packages/rope/base/libutils.pypath_to_resourcer   	   s     1$??L 5y(22488)#2244 2##L111v~ .---x 0!!,///4    c                 ,    t          | j        |          S N)relativeaddress)r   r   s     r   r	   r	   !   s    GOT***r   c                    t           j        j                            |                               t
          j        j        d          } t           j        j                            |                              t
          j        j        d          }|| k    rdS |                    | dz             r|t          |           dz   d          S d S )N/    )
r
   r   r   r   replaceosr   sep
startswithlen)rootr   s     r   r   r   %   s    9&&t,,44RW[#FFD9&&t,,44RW[#FFDt| rtcz"" %CIIMOO$$% %r   c                     t          | |          }|dS t          | j                  D ]}|                    |           | j        j        r(t          j        j                            | ||           dS dS )z|Report that the contents of file at `path` was changed

    The new contents of file is retrieved by reading the file.

    N)	r   list	observersresource_changedpycoreautomatic_soar
   r   perform_soa_on_changed_scopes)r   r   old_contentresourceobservers        r   report_changer0   /   s      ..H *++ , ,!!(++++~# W	66w+VVVVVW Wr   c                 :    | j                             |           dS )zwPerform static object analysis on a python file in the project

    Note that this might be really time consuming.
    N)r*   analyze_moduler   r.   s     r   r2   r2   >   s     
 N!!(+++++r   c                     |                                  }|                    dt          |                    }|D ]@}|                    |j                   t          | |           |                                 AdS )zzPerform static object analysis on all python files in the project

    Note that this might be really time consuming.
    zAnalyzing ModulesN)get_python_filescreate_jobsetr$   started_jobr   r2   finished_job)r   task_handle	resourcesjob_setr.   s        r   analyze_modulesr<   F   s    
 ((**I''(;S^^LLG  HM***w))) r   Fc                 <    t          j        | j        |||          S )zReturns a `PyObject` object for the given code

    If `force_errors` is `True`, `exceptions.ModuleSyntaxError` is
    raised if module has syntax errors.  This overrides
    ``ignore_syntax_errors`` project config.

    )force_errors)r   PyModuler*   )r   coder.   r>   s       r   get_string_modulerA   S   s)      h\   r   c                 H    t          | ||                                          S )z+Returns a `Scope` object for the given code)rA   	get_scope)r   r@   r.   s      r   get_string_scoperD   `   s     WdH55??AAAr   c                 6    | j                             |          S r   )r*   is_python_filer3   s     r   rF   rF   e   s    >((222r   c                 h   |                                  r| j        }| j        }n:| j        dk    r| j        j        }| j        j        }n| j        d d         }| j        }||j        k    rI|                    d          r4|j        dz   |z   }|j        }||j        k    r|                    d          4|S )Nz__init__.py.)	is_foldernameparent	has_child)r.   module_namesource_folders      r   modnamerP   i   s     (m 	-	' (o* .mCRC( 
=/
/ -M4K4K5 5 - $(3.<%,	 =/
/ -M4K4K5 5 - r   r   )NF)__doc__os.pathr!   rope.base.projectr
   rope.base.pycore	rope.baser   r   r   r   r	   
deprecatedr   r0   r2   DEFAULT_TASK_HANDLEr<   rA   rD   rF   rP    r   r   <module>rY      s%   8 8          5 5 5 5 5 5 5 5 5 5   0+ + + % % %W W W, , , *4)G 
 
 
 

 
 
 
B B B B
3 3 3    r   