Format: application/x-python-code
⬇ Download File (7.0 KB)
   1  o
   2  
   3  ��h(�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	m
   4  Z
   5  ddlmZddlZ
   6  e�d�Zd	e
   7  j	e
   8  jeeffd
   9  d�ZGdd
  10  �d
  11  e�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)zE
  12  System command aliases.
  13  
  14  Authors:
  15  
  16  * Fernando Perez
  17  * Brian Granger
  18  �N)�Configurable�)�
  19  UsageError)�List�Instance)�errorz^(\s*)()(\S+)(.*$)�returncCs|tjdkr/gd�}tj�d�rgd�}ntj�d�s tj�d�r%gd�}ngd�}||}|Stjd	vr:gd
  20  �}|Sg}|S)z1Return list of shell aliases to auto-define.
  21      �posix)��mkdirr��rmdirr
  22  )�mvr)�rmr)�cpr)�catr�linux))�lsz
  23  ls -F --color)�llzls -F -o --color)�lfzls -F -o --color %l | grep ^-)�lkzls -F -o --color %l | grep ^l)�ldirzls -F -o --color %l | grep /$)�lxz ls -F -o --color %l | grep ^-..xZopenbsdZnetbsd))rzls -F)rzls -F -l)rzls -F -l %l | grep ^-)rzls -F -l %l | grep ^l)rzls -F -l %l | grep /$)rzls -F -l %l | grep ^-..x))rzls -F -G)rzls -F -l -G)rzls -F -l -G %l | grep ^-)rzls -F -l -G %l | grep ^l)rzls -F -G -l %l | grep /$)rzls -F -l -G %l | grep ^-..x)�nt�dos))rzdir /on)�ddir�dir /ad /on)rrr
  24  r)�echor)�renr)�copyr)�os�name�sys�platform�
  25  startswith)�default_aliasesZ
  26  ls_aliases�r&�Hc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/alias.pyr%+s
  27  
  28  
  29  
  30  
  31  
  32  ��r%c@�eZdZdS)�
  33  AliasErrorN��__name__�
  34  __module__�__qualname__r&r&r&r'r)t�r)c@r()�InvalidAliasErrorNr*r&r&r&r'r/xr.r/c@s:eZdZdZhd�Zdd�Zdd�Zdd�Zd
  35  d
  36  d�ZdS)�Aliasz�Callable object storing the details of one alias.
  37  
  38      Instances are registered as magic functions to allow use of aliases.
  39      >Zpushd�cdZpopd�aliasZunaliasZdhistcCs,||_||_||_d�|�|_|��|_dS)NzAlias for `!{}`)�shellr!�cmd�format�__doc__�validate�nargs)�selfr3r!r4r&r&r'�__init__�s
  40  zAlias.__init__cCs�|j|jvr
  41  td|j��z|jjjd|j}Wn	ty"Yn
  42  wt|t�s/td|j��t|j	t
  43  �s<td|j	��|j	�d�|j	�d�}|dkrX|j	�d�dkrXtd	��|S)
  44  z7Validate the alias, and return the number of arguments.z@The name %s can't be aliased because it is a keyword or builtin.�linezAThe name %s can't be aliased because it is another magic command.z*An alias command must be a string, got: %r�%s�%%sr�%lzEThe %s and %l specifiers are mutually exclusive in alias definitions.)
  45  r!�	blacklistr/r3�magics_manager�magics�KeyError�
  46  isinstancer0r4�str�count�find)r9�callerr8r&r&r'r7�s*��
  47  ��zAlias.validatecCsd�|j|j�S)Nz<alias {} for {!r}>)r5r!r4�r9r&r&r'�__repr__�szAlias.__repr__�cCs�|j}|j}|�d�dkr|�d|�}d}|dkr-|�d�dkr&|�dd�}d||f}n-|�d|�}t|�|krEtd|j|t|�f��d|t|d|��d	�	||d��f}|j
  48  �|�dS)
  49  Nr>rrJr=rr<z%s %sz+Alias <%s> requires %s arguments, %s given.� )r4r8rF�replace�split�lenrr!�tuple�joinr3�system)r9�restr4r8�argsr&r&r'�__call__�s �*zAlias.__call__N)rJ)	r+r,r-r6r?r:r7rIrTr&r&r&r'r0{sr0cs�eZdZUee��jdd�Zeed<egd�jdd�Zeed<eddd�Z	d�fd	d
  50  �	Z
  51  dd�Zed
  52  d��Z
  53  dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�ZS)�AliasManagerT)�configr%)�
  54  default_value�user_aliasesz1IPython.core.interactiveshell.InteractiveShellABC)�
  55  allow_noneNcsDtt|�jdd|i|��|jdur |jjjd|_|��dSdS)Nr3r;r&)�superrUr:r3r@rA�
  56  linemagics�init_aliases)r9r3�kwargs��	__class__r&r'r:�s
  57  
  58  �zAliasManager.__init__cCsR|j|jD] \}}|�d�r |jdur |jjdkr |�dd�}|�||�qdS)Nzls ZNoColorz --colorrJ)r%rXr$r3�colorsrL�soft_define_alias)r9r!r4r&r&r'r\�s�
  59  �zAliasManager.init_aliasescCsdd�|j��D�S)NcSs$g|]\}}t|t�r||jf�qSr&)rCr0r4)�.0�n�funcr&r&r'�
  60  <listcomp>�s�z(AliasManager.aliases.<locals>.<listcomp>)r[�itemsrHr&r&r'�aliases�szAliasManager.aliasesc
  61  CsFz	|�||�WdSty"}z
  62  td|�WYd}~dSd}~ww)z2Define an alias, but don't raise on an AliasError.zInvalid alias: %sN)�define_aliasr)r)r9r!r4�er&r&r'ra�s��zAliasManager.soft_define_aliascCs(t|j||d�}|jjj|d|d�dS)z�Define a new alias after validating it.
  63  
  64          This will raise an :exc:`AliasError` if there are validation
  65          problems.
  66          )r3r!r4r;)Z
  67  magic_kindZ
  68  magic_nameN)r0r3r@Zregister_function)r9r!r4rGr&r&r'rh�s
  69  �zAliasManager.define_aliascCs |j�|d�}t|t�r|SdS)z9Return an alias, or None if no alias by that name exists.N)r[�getrCr0)r9r!Zanamer&r&r'�	get_alias�szAliasManager.get_aliascCs|�|�duS)z?Return whether or not a given name has been defined as an aliasN)rk�r9r!r&r&r'�is_alias�szAliasManager.is_aliascCs"|�|�r|j|=dStd|��)N�%s is not an alias)rmr[�
  70  ValueErrorrlr&r&r'�undefine_alias�s
  71  zAliasManager.undefine_aliascCs|jD]	\}}|�|�qdS�N)rgrp)r9r!�_r&r&r'�
  72  clear_aliasess�zAliasManager.clear_aliasescCs |�|�}|r
  73  |jStd|��)z/Retrieve the command to which an alias expands.rn)rkr4ro)r9r!rGr&r&r'�retrieve_aliass
  74  zAliasManager.retrieve_aliasrq)r+r,r-rr%�tag�__annotations__rXrr3r:r\�propertyrgrarhrkrmrprsrt�
  75  __classcell__r&r&r^r'rU�s"
  76  �
  77  
  78  rU)r6r �rer"Ztraitlets.config.configurablerrrZ	traitletsrr�logging�typing�t�compileZshell_line_split�TuplerDr%�	Exceptionr)r/�objectr0rUr&r&r&r'�<module>s
  79  IH