Format: application/x-python-code
⬇ Download File (9.4 KB)
   1  o
   2  
   3  ��h�)�@sdZddlZddlmZddlmZmZddlmZddl	m
   4  Z
   5  ddlmZm
   6  Z
   7  ddlmZmZmZmZd	Zd
   8  ZdZdZd
   9  ZdZdd�Zdd�ZGdd�de�ZGdd�de�ZiZe�e�e�d�dddiidfed<dddiidfed<Gdd�de�Z Gd d!�d!e�Z!dS)"zx
  10  An application for managing IPython profiles.
  11  
  12  To be invoked as the `ipython profile` subcommand.
  13  
  14  Authors:
  15  
  16  * Min RK
  17  
  18  �N)�Application)�BaseIPythonApplication�
  19  base_flags)�
  20  ProfileDir)�import_item)�get_ipython_dir�get_ipython_package_dir)�Unicode�Bool�Dict�observea&Create an IPython profile by name
  21  
  22  Create an ipython profile directory by its name or
  23  profile directory path. Profile directories contain
  24  configuration, log and security related files and are named
  25  using the convention 'profile_<name>'. By default they are
  26  located in your ipython directory. Once created, you will
  27  can edit the configuration files in the profile
  28  directory to configure IPython. Most users will create a
  29  profile directory by name,
  30  `ipython profile create myprofile`, which will put the directory
  31  in `<ipython_dir>/profile_myprofile`.
  32  z�List available IPython profiles
  33  
  34  List all available profiles, by profile location, that can
  35  be found in the current working directly or in the ipython
  36  directory. Profile directories are named using the convention
  37  'profile_<profile>'.
  38  a-Manage IPython profiles
  39  
  40  Profile directories contain
  41  configuration, log and security related files and are named
  42  using the convention 'profile_<name>'. By default they are
  43  located in your ipython directory.  You can create profiles
  44  with `ipython profile create <name>`, or see the profiles you
  45  already have with `ipython profile list`
  46  
  47  To get started configuring IPython, simply do:
  48  
  49  $> ipython profile create
  50  
  51  and IPython will create the default profile in <ipython_dir>/profile_default,
  52  where you can edit ipython_config.py to start configuring IPython.
  53  
  54  z)ipython profile list  # list all profilesz�
  55  ipython profile create foo         # create profile foo w/ default config files
  56  ipython profile create foo --reset # restage default config files over current
  57  ipython profile create foo --parallel # also stage parallel config files
  58  z�
  59  ipython profile create -h  # show the help string for the create subcommand
  60  ipython profile list -h    # show the help string for the list subcommand
  61  
  62  ipython locate profile foo # print the path to the directory for profile 'foo'
  63  cCsHg}t�|�}|D]}|��r!|j�d�r!|�|j�dd�d�q	|S)z'list profiles in a given root directoryZprofile_�_������)�os�scandir�is_dir�name�
  64  startswith�append�split)�path�profiles�files�f�r�Mc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/profileapp.py�list_profiles_inas
  65  �rcCsLtj�t�dd�}g}t�|�}|D]}|��r#|jdkr#|�|j�q|S)z,list profiles that are bundled with IPython.�core�profile�__pycache__)rr�joinrrrrr)rrrrrrr�list_bundled_profilesms
  66  �r"cs*eZdZdZd�fdd�	Zdd�Z�ZS)�
  67  ProfileLocatez(print the path to an IPython profile dirNc�*tt|��|�|jr|jd|_dSdS�Nr)�superr#�parse_command_line�
  68  extra_argsr��self�argv��	__class__rrr'}s�z ProfileLocate.parse_command_linecCst|jj�dS�N)�print�profile_dir�location�r*rrr�start�szProfileLocate.startr.)�__name__�
  69  __module__�__qualname__�descriptionr'r3�
  70  __classcell__rrr,rr#zsr#c@sneZdZdZeZeZeddd��Z	ee
  71  dddiidfd	��Zee
  72  �d
  73  d�jdd
  74  �Zdd�Zdd�Zdd�ZdS)�ProfileList�ipython-profilezProfileList.ipython_dirzApplication.log_level)zipython-dirz	log-levelr�	log_levelrz6Set Application.log_level to 0, maximizing log output.)�debuga
  75          The name of the IPython directory. This directory is used for logging
  76          configuration (through profiles), history storage, etc. The default
  77          is usually $HOME/.ipython. This options can also be specified through
  78          the environment variable IPYTHONDIR.
  79          ��helpT��configcCs|D]}td|�qdS)z!print list of profiles, indented.z    %sN)r/)r*rrrrr�_print_profiles�s�zProfileList._print_profilescCs�t�}|r#t�td�|�|�t�td�td|j�td�t|j�}|r9t�td|j�|�|�tt���}|rHt�td�t�td�td�t�dS)	NzAvailable profiles in IPython:z8    The first request for a bundled profile will copy itz%    into your IPython directory (%s),z    where you can customize it.zAvailable profiles in %s:zLProfiles from CWD have been removed for security reason, see CVE-2022-21699:z5To use any of the above profiles, start IPython with:z    ipython --profile=<name>)r"r/rA�ipython_dirrr�getcwd)r*rrrr�list_profile_dirs�s0
  80  
  81  
  82  �
  83  zProfileList.list_profile_dirscCs|��dSr.)rDr2rrrr3�szProfileList.startN)r4r5r6r�	list_helpr7�_list_examples�examplesr�aliases�dict�flagsr	r�tagrBrArDr3rrrrr9�s*�
  84  ����
  85  r9�init�
  86  ProfileCreate�	overwriteTz3reset config files in this profile to the defaults.�reset�parallelzSInclude the config files for parallel computing apps (ipengine, ipcontroller, etc.)cs�eZdZdZeZeZed�j	dd�Z
  87  dd�Zdd�Zedd	d
  88  �j	dd�Z
  89  ed�dd
  90  ��Z�fdd�Zee�ZegZdd�Z�fdd�Zdd�Z�ZS)rMr:Tr?cC�dS)Nz[%(name)s] %(message)srr2rrr�_log_format_default��z!ProfileCreate._log_format_defaultcCrQ)NTrr2rrr�_copy_config_files_default�rSz(ProfileCreate._copy_config_files_defaultFz2whether to include parallel computing config filesr=rPcCsNgd�}|dr|D]}|j�|�q
  91  dS|D]
  92  }||jvr$|j�|�qdS)N)zipcontroller_config.pyzipengine_config.pyzipcluster_config.py�new)�config_filesr�remove)r*ZchangeZparallel_files�cfrrr�_parallel_changed�s�
  93  ��zProfileCreate._parallel_changedcr$r%)r&rMr'r(rr)r,rrr'�s�z ProfileCreate.parse_command_linecCsjd}|�dd�d}zt|�}W|Sty"|j�d|�Y|Sty4|jjd|dd�Y|Sw)	zimport an app classN�.rrz0Couldn't import %s, config file will be excludedzUnexpected error importing %sT)�exc_info)�rsplitr�ImportError�log�info�	Exception�warning)r*�app_path�apprrrr�_import_app�s
  94  ���zProfileCreate._import_appc	s�tt|���ddlm}|g}dD]}|�|�}|dur"|�|�q|jr@ddlm	}ddl
  95  m}ddlm
  96  }|�|||g�|D]#}|�}|j�|j�|j|_|j|_d|_|j|_|j|_|��qBdS)Nr)�TerminalIPythonApp)zipykernel.kernelapp.IPKernelApp)�IPControllerApp)�IPEngineApp)�IPClusterStartT)r&rM�init_config_filesZIPython.terminal.ipapprerdrrPZ ipyparallel.apps.ipcontrollerapprfZipyparallel.apps.ipengineapprgZipyparallel.apps.ipclusterapprh�extendr@�updater^rNZcopy_config_filesrBr0)	r*reZappsrbrcrfrgrhZAppr,rrris6
  97  
  98  ��
  99  �zProfileCreate.init_config_filescCsdSr.rr2rrr�stage_default_config_file!rSz'ProfileCreate.stage_default_config_file)r4r5r6r�create_helpr7�_create_examplesrGr
 100  rKZauto_createrRrTrPrrYr'r�create_flagsrJr�classesrdrirlr8rrr,rrM�s(��
 101  
 102  c@s\eZdZdZeZeZee	e
 103  e
 104  j��dfeej��dfe
 105  e
 106  j��dfd��Zdd�ZdS)�
 107  ProfileAppzipython profiler)�create�listZlocatecCsP|jdur#tdd�tt|j��d�|��|��|�d�dS|j�	�S)Nz.No subcommand specified. Must specify one of: z, z.
 108  r)
 109  Zsubappr/r!�map�repr�subcommandsZprint_descriptionZprint_subcommands�exitr3r2rrrr30s
 110  ���
 111  zProfileApp.startN)r4r5r6r�profile_helpr7�_main_examplesrGrrIrM�
 112  splitlinesr9r#rvr3rrrrrq%s�rq)"�__doc__rZtraitlets.config.applicationrZIPython.core.applicationrrZIPython.core.profiledirrZIPython.utils.importstringrZ
 113  IPython.pathsrrZ	traitletsr	r
 114  rrrmrErxrFrnryrr"r#r9rork�poprMrqrrrr�<module>s:
 115  
 116  ?
 117  
 118  
 119  �
 120  �U