
v^-                 @   s?   d  d l  m Z d d   d d  Z Gd d   d e  Z d S)	    )BaseCommandc             C   s   |  j  d  p |  j   S)N_)
startswithisupper)k r   N/tmp/pip-build-8lau8j11/django/django/core/management/commands/diffsettings.py<lambda>   s    r	   c                s       f d d   t     D S)z2Convert a module namespace to a Python dictionary.c                s4   i  |  ]* }  |  s t  t   |   |  q Sr   )reprgetattr).0r   )module	omittabler   r   
<dictcomp>   s   	 z"module_to_dict.<locals>.<dictcomp>)dir)r   r   r   )r   r   r   module_to_dict   s    r   c               @   sL   e  Z d  Z d Z d Z d d   Z d d   Z d d   Z d	 d
   Z d S)CommandzWDisplays differences between the current settings.py and Django's
    default settings.Fc             C   sU   | j  d d d d d | j  d d d d d	 | j  d
 d d d d d d d  S)Nz--allaction
store_truehelpzfDisplay all settings, regardless of their value. In "hash" mode, default values are prefixed by "###".z	--defaultmetavarMODULEzvThe settings module to compare the current settings against. Leave empty to compare against Django's default settings.z--outputdefaulthashchoicesunifieda  Selects the output format. 'hash' mode displays each changed setting, with the settings that don't appear in the defaults followed by ###. 'unified' mode prefixes the default setting with a minus sign, followed by the changed setting prefixed with a plus sign.)zhashr   )add_argument)selfparserr   r   r   add_arguments   s    zCommand.add_argumentsc       	      K   s   d d l  m } m } m } | j s/ | j   t | j  } | d } t | r] | |  n |  } d |  j d |  j	 i | d } d j
 | | | |   S)Nr   )settingsSettingsglobal_settingsr   r   r   output
)Zdjango.confr    r!   r"   Z
configured_setupr   Z_wrappedoutput_hashoutput_unifiedjoin)	r   optionsr    r!   r"   user_settingsr   default_settingsZoutput_funcr   r   r   handle)   s    	

	zCommand.handlec             K   s   g  } x t  |  D] } | | k rC | j d | | | f  q | | | | k ru | j d | | | f  q | d r | j d | | | f  q W| S)Nz%s = %s  ###z%s = %sallz### %s = %s)sortedappend)r   r*   r+   r)   r#   keyr   r   r   r&   9   s    
zCommand.output_hashc             K   s   g  } x t  |  D] } | | k rO | j |  j j d | | | f   q | | | | k r | j |  j j d | | | f   | j |  j j d | | | f   q | d r | j d | | | f  q W| S)Nz	+ %s = %sz	- %s = %sr-   z	  %s = %s)r.   r/   styleSUCCESSERROR)r   r*   r+   r)   r#   r0   r   r   r   r'   E   s    *'*
zCommand.output_unifiedN)	__name__
__module____qualname__r   Zrequires_system_checksr   r,   r&   r'   r   r   r   r   r   	   s   r   N)Zdjango.core.management.baser   r   r   r   r   r   r   <module>   s   