Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib
/
python3.5
/
site-packages
/
setuptools
/
__pycache__
/
File Content:
config.cpython-35.opt-1.pyc
i�Re�? � @ s d d l m Z m Z d d l Z d d l Z d d l 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 d d d d � Z d d � Z d d d � Z Gd d � d e � Z Gd d � d e � Z Gd d � d e � Z d S)� )�absolute_import�unicode_literalsN)�defaultdict)�partial)�DistutilsOptionError�DistutilsFileError)� import_module)�string_typesFc C s� d d l m } m } t j j | � } t j j | � sJ t d | � � t j � } t j t j j | � � zi | � } | r� | j � n g } | | k r� | j | � | j | d | �t | | j d | �} Wd t j | � Xt | � S)a, Read given configuration file and returns options from it as a dict. :param str|unicode filepath: Path to configuration file to get options from. :param bool find_others: Whether to search for other configuration files which could be on in various places. :param bool ignore_option_errors: Whether to silently ignore options, values of which could not be resolved (e.g. due to exceptions in directives such as file:, attr:, etc.). If False exceptions are propagated as expected. :rtype: dict r )�Distribution� _Distributionz%Configuration file %s does not exist.� filenames�ignore_option_errorsN)Zsetuptools.distr r �os�path�abspath�isfiler �getcwd�chdir�dirnameZfind_config_files�appendZparse_config_files�parse_configuration�command_options�configuration_to_dict) �filepathZfind_othersr r r Zcurrent_directoryZdistr �handlers� r � /config.py�read_configuration s$ r c C s� t t � } x | D]w } | j } | j } x\ | j D]Q } t | d | d � } | d k ro t | | � } n | � } | | | | <q5 Wq W| S)z�Returns configuration data gathered by given handlers as a dict. :param list[ConfigHandler] handlers: Handlers list, usually from parse_configuration() :rtype: dict zget_%sN)r �dict�section_prefix� target_obj�set_options�getattr)r Zconfig_dict�handlerZ obj_aliasr Zoption�getter�valuer r r r <