Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
usr
/
lib
/
python2.7
/
site-packages
/
awscli
/
customizations
/
configure
/
File Content:
writer.pyc
� =��Xc @ sB d d l Z d d l Z d d l m Z d e f d � � YZ d S( i����Ni ( t SectionNotFoundErrort ConfigFileWriterc B sq e Z e j d � Z e j d � Z d � Z d � Z d � Z d � Z d � Z d � Z d d � Z d � Z RS( s \[(?P<header>[^]]+)\]s7 (?P<option>[^:=][^:=]*)\s*(?P<vi>[:=])\s*(?P<value>.*)$c C s� | j d d � } t j j | � sH | j | � | j | | | � d St | d � � } | j � } Wd QXyE | j | | | � t | d � � } | j d j | � � Wd QXWn$ t k r� | j | | | � n Xd S( s� Update config file with new values. This method will update a section in a config file with new key value pairs. This method provides a few conveniences: * If the ``config_filename`` does not exist, it will be created. Any parent directories will also be created if necessary. * If the section to update does not exist, it will be created. * Any existing lines that are specified by ``new_values`` **will not be touched**. This ensures that commented out values are left unaltered. :type new_values: dict :param new_values: The values to update. There is a special key ``__section__``, that specifies what section in the INI file to update. If this key is not present, then the ``default`` section will be updated with the new values. :type config_filename: str :param config_filename: The config filename where values will be written. t __section__t defaultNt rt wt ( t popt ost patht isfilet _create_filet _write_new_sectiont opent readlinest _update_section_contentst writet joinR ( t selft new_valuest config_filenamet section_namet ft contents( ( sF /tmp/pip-build-uEGWVr/awscli/awscli/customizations/configure/writer.pyt update_config s c C sn t j j | � d } t j j | � s8 t j | � n t j t j | t j t j Bd � d � � Wd QXd S( Ni i� R ( R R t splitt isdirt makedirst fdopenR t O_WRONLYt O_CREAT( R R t dirname( ( sF /tmp/pip-build-uEGWVr/awscli/awscli/customizations/configure/writer.pyR F s c C se t | d � �P } | j d | � g } | j d d d | d | � | j d j | � � Wd QXd S( Nt as [%s] t line_numberi R R R ( R R t _insert_new_valuesR ( R R R R R R ( ( sF /tmp/pip-build-uEGWVr/awscli/awscli/customizations/configure/writer.pyR O s c C s� xs t t | � � D]_ } | | } | j � j d � r>