'The JJBConfig class is intended to encapsulate and resolve priority
between all sources of configuration for the JJB library. This allows
the various sources of configuration to provide a consistent accessor
interface regardless of where they are used.
It also allows users of JJB-as-an-API to create minimally valid
configuration and easily make minor modifications to default values
without strictly adhering to the confusing setup (see the _setup
method, the behavior of which largely lived in the cmd.execute method
previously) necessary for the jenkins-jobs command line tool.
:arg str config_filename: Name of configuration file on which to base
this config object.
:arg bool config_file_required: Allows users of the JJBConfig class to
decide whether or not it\'s really necessary for a config file to be
passed in when creating an instance. This has two effects on the
behavior of JJBConfig initialization:
* It determines whether or not we try "local" and "global" config
files.
* It determines whether or not failure to read some config file
will raise an exception or simply print a warning message
indicating that no config file was found.'

def __init__(self, config_filename=None, config_file_required=False, config_section='jenkins'):

    config_parser = self._init_defaults()
    global_conf = '/etc/jenkins_jobs/jenkins_jobs.ini'
    user_conf = os.path.join(os.path.expanduser('~'), '.config', 'jenkins_jobs', 'jenkins_jobs.ini')
    local_conf = os.path.join(os.path.dirname(__file__), 'jenkins_jobs.ini')
    conf = None
    if (config_filename is not None):
        conf = config_filename
    elif os.path.isfile(local_conf):
        conf = local_conf
    elif os.path.isfile(user_conf):
        conf = user_conf
    else:
        conf = global_conf
    if (config_file_required and (conf is None)):
        raise JJBConfigException(CONFIG_REQUIRED_MESSAGE)
    config_fp = None
    if (conf is not None):
        try:
            config_fp = self._read_config_file(conf)
        except JJBConfigException:
            if config_file_required:
                raise JJBConfigException(CONFIG_REQUIRED_MESSAGE)
            else:
                logger.warning('Config    file,    {0},    not    found.    Using    default    config    values.'.format(conf))
    if (config_fp is not None):
        if PY2:
            config_parser.readfp(config_fp)
        else:
            config_parser.read_file(config_fp)
    self.config_parser = config_parser
    self.ignore_cache = False
    self.flush_cache = False
    self.user = None
    self.password = None
    self.section = config_section
    self.plugins_info = None
    self.timeout = builder._DEFAULT_TIMEOUT
    self.allow_empty_variables = None
    self.jenkins = defaultdict(None)
    self.builder = defaultdict(None)
    self.yamlparser = defaultdict(None)
    self.hipchat = defaultdict(None)
    self._setup()
