Format: application/x-python-code
1 o
2
3 ��h! � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z ddl
4 mZmZ ddl
5 mZmZmZ dd lmZ G d
6 d� de�ZG dd
7 � d
8 e�ZdS )z3An object for managing IPython profile directories.� N)�Path)�LoggingConfigurable� )�get_ipython_package_dir)�expand_path�ensure_dir_exists)�Unicode�Bool�observe)�Optionalc @ s e Zd ZdS )�ProfileDirErrorN)�__name__�
9 __module__�__qualname__� r r �Mc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/profiledir.pyr s r c @ sH e Zd ZdZed�Zed�Zed�Zed�Zed�Z ed�Z
10 ed�Zed�Zed�Z
11 ed�Zeddd �jd
12 d�Zed�Zed
13 �dd� �Zd0dedee defdd�Zed�d0dd��Zed�d0dd��Zed�d0dd��Zed�d0d d!��Zd"d#� Zd1d$ededefd%d&�Z e!d0d'd(��Z"e!d2d*d+��Z#e!d2d,d-��Z$e!d0d.d/��Z%dS )3�
14 ProfileDira@ An object to manage the profile directory and its resources.
15
16 The profile directory is used by all IPython applications, to manage
17 configuration, logging and security.
18
19 This object knows how to find, create and manage these directories. This
20 should be used by any code that wants to handle profiles.
21 �security�logZstartup�pidZstatic� zaSet the profile location directly. This overrides the logic used by the
22 `profile` option.)�helpT)�configF�locationc C s� | j rtd��d| _ |d }t|� tj�|| j�| _tj�|| j�| _ tj�|| j
23 �| _tj�|| j�| _
24 tj�|| j�| _| �� d S )Nz+Cannot set profile location more than once.T�new)�_location_isset�RuntimeErrorr �os�path�join�security_dir_name�security_dir�log_dir_name�log_dir�startup_dir_name�startup_dir�pid_dir_name�pid_dir�static_dir_name�
25 static_dir�
26 check_dirs)�self�changer r r r �_location_changed: s zProfileDir._location_changedNr �mode�returnc
27 C s� t j�|�r-|r+t �|�j|kr+z t �||� W dS ty* | j�d|� Y dS w dS z|r9t � ||� W dS t � |� W dS tyZ } z|j
28 t
29 jkrUW Y d}~dS � d}~ww )a� ensure a directory exists at a given path
30
31 This is a version of os.mkdir, with the following differences:
32
33 - returns whether the directory has been created or not.
34 - ignores EEXIST, protecting against race conditions where
35 the dir may have been created in between the check and
36 the creation
37 - sets permissions if requested and the dir already exists
38
39 Parameters
40 ----------
41 path: str
42 path of the dir to create
43 mode: int
44 see `mode` of `os.mkdir`
45
46 Returns
47 -------
48 bool:
49 returns True if it created the directory, False otherwise
50 zCould not set permissions on %sFNT)r r �exists�stat�st_mode�chmod�OSErrorr �warning�mkdir�errno�EEXIST)r+ r r. �er r r �_mkdirJ s2 ��� ����zProfileDir._mkdirr# c C s | � | j� d S �N)r: r# �r+ r, r r r �
51 check_log_diry s zProfileDir.check_log_dirr% c C sr | � | j�r7tj�| jd�}tj�t� ddd�}tj�|�r.tj�|�s,t�||� d S d S | j �
52 d|� d S d S )NZREADME�core�profileZREADME_STARTUPzLCould not copy README_STARTUP to startup dir. Source file %s does not exist.)r: r% r r r r r0 �shutil�copyr r5 )r+ r, Zreadme�srcr r r �check_startup_dir} s
53 ����zProfileDir.check_startup_dirr! c C � | � | jd� d S �Ni�A )r: r! r<