ó
æNXc           @  s˜  d  Z  d d l m Z d d l Z d d l m Z d d l m Z m Z d d l	 m
 Z
 d d l m Z d d l m Z m Z d d	 l m Z d d
 l m Z m Z m Z d Z d Z d Z d Z d Z d Z d „  Z d „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ i  Z  e  j! e ƒ e  j" d ƒ i i e# d 6d 6d f e  d <i i e# d 6d 6d f e  d <d e f d „  ƒ  YZ$ d e f d  „  ƒ  YZ% d S(!   sx   
An application for managing IPython profiles.

To be invoked as the `ipython profile` subcommand.

Authors:

* Min RK

iÿÿÿÿ(   t   print_functionN(   t   Application(   t   BaseIPythonApplicationt
   base_flags(   t
   ProfileDir(   t   import_item(   t   get_ipython_dirt   get_ipython_package_dir(   t	   py3compat(   t   Unicodet   Boolt   Dicts&  Create an IPython profile by name

Create an ipython profile directory by its name or
profile directory path. Profile directories contain
configuration, log and security related files and are named
using the convention 'profile_<name>'. By default they are
located in your ipython directory. Once created, you will
can edit the configuration files in the profile
directory to configure IPython. Most users will create a
profile directory by name,
`ipython profile create myprofile`, which will put the directory
in `<ipython_dir>/profile_myprofile`.
sê   List available IPython profiles

List all available profiles, by profile location, that can
be found in the current working directly or in the ipython
directory. Profile directories are named using the convention
'profile_<profile>'.
s-  Manage IPython profiles

Profile directories contain
configuration, log and security related files and are named
using the convention 'profile_<name>'. By default they are
located in your ipython directory.  You can create profiles
with `ipython profile create <name>`, or see the profiles you
already have with `ipython profile list`

To get started configuring IPython, simply do:

$> ipython profile create

and IPython will create the default profile in <ipython_dir>/profile_default,
where you can edit ipython_config.py to start configuring IPython.

s)   ipython profile list  # list all profilessé   
ipython profile create foo         # create profile foo w/ default config files
ipython profile create foo --reset # restage default config files over current
ipython profile create foo --parallel # also stage parallel config files
sç   
ipython profile create -h  # show the help string for the create subcommand
ipython profile list -h    # show the help string for the list subcommand

ipython locate profile foo # print the path to the directory for profile 'foo'
c         C  s›   t  j |  ƒ } g  } x | D]w } y t  j j |  | ƒ } Wn t k
 rQ q n Xt  j j | ƒ r | j d ƒ r | j | j d d ƒ d ƒ q q W| S(   s'   list profiles in a given root directoryt   profile_t   _i   iÿÿÿÿ(	   t   ost   listdirt   patht   joint   UnicodeErrort   isdirt
   startswitht   appendt   split(   R   t   filest   profilest   ft	   full_path(    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   list_profiles_inc   s    !$c          C  sˆ   t  j j t ƒ  d d ƒ }  t  j |  ƒ } g  } xQ | D]I } t  j j |  | ƒ } t  j j | ƒ r7 | d k r7 | j | ƒ q7 q7 W| S(   s,   list profiles that are bundled with IPython.u   coreu   profilet   __pycache__(   R   R   R   R   R   R   R   (   R   R   R   t   profileR   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   list_bundled_profilesq   s    t   ProfileLocatec           B  s#   e  Z d  Z d d „ Z d „  Z RS(   s(   print the path to an IPython profile dirc         C  s6   t  t |  ƒ j | ƒ |  j r2 |  j d |  _ n  d  S(   Ni    (   t   superR   t   parse_command_linet
   extra_argsR   (   t   selft   argv(    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyR!   €   s    	c         C  s   t  |  j j ƒ d  S(   N(   t   printt   profile_dirt   location(   R#   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   start…   s    N(   t   __name__t
   __module__t   descriptiont   NoneR!   R(   (    (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyR   }   s   t   ProfileListc           B  s“   e  Z d  Z e Z e Z e i d d 6d d 6ƒ Z e e	 d i i d d 6d 6d	 f ƒ ƒ Z
 e e ƒ  d
 e d d ƒZ d „  Z d „  Z d „  Z RS(   u   ipython-profiles   ProfileList.ipython_dirs   ipython-dirs   Application.log_levels	   log-levelt   debugi    t	   log_levelR   s6   Set Application.log_level to 0, maximizing log output.t   configt   helps  
        The name of the IPython directory. This directory is used for logging
        configuration (through profiles), history storage, etc. The default
        is usually $HOME/.ipython. This options can also be specified through
        the environment variable IPYTHONDIR.
        c         C  s#   x | D] } t  d | ƒ q Wd S(   s!   print list of profiles, indented.s       %sN(   R%   (   R#   R   R   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   _print_profiles¢   s    c         C  s  t  ƒ  } | r\ t ƒ  t d ƒ |  j | ƒ t ƒ  t d ƒ t d |  j ƒ t d ƒ n  t |  j ƒ } | r™ t ƒ  t d |  j ƒ |  j | ƒ n  t t j ƒ  ƒ } | rÜ t ƒ  t d t j ƒ  ƒ |  j | ƒ n  t ƒ  t d ƒ t d ƒ t ƒ  d  S(	   Ns   Available profiles in IPython:s8       The first request for a bundled profile will copy its%       into your IPython directory (%s),s       where you can customize it.s   Available profiles in %s:s-   Available profiles in current directory (%s):s5   To use any of the above profiles, start IPython with:s       ipython --profile=<name>(   R   R%   R2   t   ipython_dirR   R   t   getcwd(   R#   R   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   list_profile_dirs§   s.    	



c         C  s   |  j  ƒ  d  S(   N(   R5   (   R#   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyR(   Ã   s    (   R)   R*   t   namet	   list_helpR+   t   _list_examplest   examplesR   t   aliasest   dictt   flagsR	   R   t   TrueR3   R2   R5   R(   (    (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyR-   ‰   s   				t   initt	   overwritet   ProfileCreates3   reset config files in this profile to the defaults.t   resett   parallelsS   Include the config files for parallel computing apps (ipengine, ipcontroller, etc.)c           B  s˜   e  Z d  Z e Z e Z e e d e	 ƒZ
 d „  Z d „  Z e e	 d e d d ƒZ d „  Z d „  Z e e ƒ Z e g Z d „  Z d	 „  Z d
 „  Z RS(   u   ipython-profileR0   c         C  s   d S(   Ns   [%(name)s] %(message)s(    (   R#   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   _log_format_default×   s    c         C  s   t  S(   N(   R=   (   R#   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   _copy_config_files_defaultÚ   s    R1   s2   whether to include parallel computing config filesc         C  sp   d d d g } | r9 xT | D] } |  j  j | ƒ q Wn3 x0 | D]( } | |  j  k r@ |  j  j | ƒ q@ q@ Wd  S(   Ns   ipcontroller_config.pys   ipengine_config.pys   ipcluster_config.py(   t   config_filesR   t   remove(   R#   R6   t   oldt   newt   parallel_filest   cf(    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   _parallel_changedß   s    	c         C  s6   t  t |  ƒ j | ƒ |  j r2 |  j d |  _ n  d  S(   Ni    (   R    R@   R!   R"   R   (   R#   R$   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyR!   ì   s    	c         C  s€   d } | j d d ƒ d } y t | ƒ } WnM t k
 rR |  j j d | ƒ n* t k
 r{ |  j j d | d t ƒn X| S(   s   import an app classt   .i   iÿÿÿÿs0   Couldn't import %s, config file will be excludeds   Unexpected error importing %st   exc_infoN(	   R,   t   rsplitR   t   ImportErrort   logt   infot	   Exceptiont   warnR=   (   R#   t   app_patht   appR6   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   _import_appö   s    c   	      C  s.  t  t |  ƒ j ƒ  d d l m } | g } x9 d D]1 } |  j | ƒ } | d  k	 r3 | j | ƒ q3 q3 W|  j rº d d l	 m
 } d d l m } d d l m } | j | | | g ƒ n  xm | D]e } | ƒ  } | j j |  j ƒ |  j | _ |  j | _ t | _ |  j | _ |  j | _ | j ƒ  qÁ Wd  S(   Niÿÿÿÿ(   t   TerminalIPythonApps   ipykernel.kernelapp.IPKernelApp(   t   IPControllerApp(   t   IPEngineApp(   t   IPClusterStart(   s   ipykernel.kernelapp.IPKernelApp(   R    R@   t   init_config_filest   IPython.terminal.ipappRW   RV   R,   R   RB   t    ipyparallel.apps.ipcontrollerappRX   t   ipyparallel.apps.ipengineappRY   t   ipyparallel.apps.ipclusterappRZ   t   extendR0   t   updateRP   R?   R=   t   copy_config_filesR3   R&   (	   R#   RW   t   appsRT   RU   RX   RY   RZ   t   App(    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyR[     s2    	
			c         C  s   d  S(   N(    (   R#   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   stage_default_config_file   s    (   R)   R*   R6   t   create_helpR+   t   _create_examplesR9   R
   R=   t   Falset   auto_createRC   RD   RB   RK   R!   R   t   create_flagsR<   R   t   classesRV   R[   Re   (    (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyR@   Ò   s   								t
   ProfileAppc        
   B  s}   e  Z d  Z e Z e Z e e d e	 e	 j j
 ƒ  d f d e e j j
 ƒ  d f d e e j j
 ƒ  d f ƒ ƒ Z d „  Z RS(   u   ipython profilet   createi    t   listt   locatec         C  sb   |  j  d  k rQ t d |  j j ƒ  ƒ t ƒ  |  j ƒ  |  j ƒ  |  j d ƒ n |  j  j ƒ  Sd  S(   Ns0   No subcommand specified. Must specify one of: %si   (	   t   subappR,   R%   t   subcommandst   keyst   print_descriptiont   print_subcommandst   exitR(   (   R#   (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyR(   /  s    

(   R)   R*   R6   t   profile_helpR+   t   _main_examplesR9   R   R;   R@   t
   splitlinesR-   R   Rq   R(   (    (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyRl   $  s   	(&   t   __doc__t
   __future__R    R   t   traitlets.config.applicationR   t   IPython.core.applicationR   R   t   IPython.core.profiledirR   t   IPython.utils.importstringR   t   IPython.pathsR   R   t   IPython.utilsR   t	   traitletsR	   R
   R   Rf   R7   Rv   R8   Rg   Rw   R   R   R   R-   Rj   Ra   t   popR=   R@   Rl   (    (    (    sO   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/profileapp.pyt   <module>   s8   		>R