Only to be used in this file and peyotl.utility.get_config
549150
def warn_from_util_logger(msg):
    """"""
    global _LOG
    # This check is necessary to avoid infinite recursion when called from get_config, because
    #   the _read_logging_conf can require reading a conf file.
    if _LOG is None and _LOGGING_CONF is None:
        sys.stderr.write('WARNING: (from peyotl before logging is configured) {}\n'.format(msg))
        return
    if _LOG is None:
        _LOG = get_logger("peyotl.utility")
    _LOG.warn(msg)
654014
def config_file(kind="local"):
    
    if kind == 'local':
        return 'setup.cfg'
    if kind == 'global':
        return os.path.join(
            os.path.dirname(distutils.__file__), 'distutils.cfg'
        )
    if kind == 'user':
        dot = os.name == 'posix' and '.' or ''
        return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot))
    raise ValueError(
        "config_file() type must be 'local', 'global', or 'user'", kind
    )
934665
def make_config_get(conf_path):
    
    project_root = _get_project_root_from_conf_path(conf_path)
    config = load_config_in_dir(project_root)
    return partial(config_get, config)
883117
def config_from_file(self, config_file=None):
        """"""
        if PYLINT_VERSION >= (1, 5):
            self.read_config_file(config_file)
            if self.cfgfile_parser.has_option('MASTER', 'load-plugins'):
                # pylint: disable=protected-access
                plugins = _splitstrip(self.cfgfile_parser.get('MASTER', 'load-plugins'))
                self.load_plugin_modules(plugins)
            self.load_config_file()
            return True

        self.load_file_configuration(config_file)
        return False
762385
def __get_config():
    '''
    
    '''
    if 'config' not in globals():
        return None
    cfg = globals().get('config', None)
    if cfg is None:
        return None

    if not isinstance(cfg, dict):
        return None
    return cfg
1343417
def get_configfile_user():
    '''
    '''
    from helpme.defaults import HELPME_CLIENT_SECRETS

    # The inital file has a funny username

    if not os.path.exists(HELPME_CLIENT_SECRETS):
        bot.debug('Generating settings file at %s' % HELPME_CLIENT_SECRETS)
        config_dir = os.path.dirname(HELPME_CLIENT_SECRETS)

        # The configuration directory might be needed for different clients
        if not os.path.exists(config_dir):
            mkdir_p(config_dir)

        name = RobotNamer().generate()

        # Generate the user config

        config = configparser.ConfigParser()
        config['DEFAULT'] = {'Alias': name }
        write_config(HELPME_CLIENT_SECRETS, config)

    return HELPME_CLIENT_SECRETS
291847
def get_configfile():
    

    ad = appdirs.AppDirs('pyfilemail')
    configdir = ad.user_data_dir
    configfile = os.path.join(configdir, 'pyfilemail.cfg')

    return configfile
1062119
def _get_config(**api_opts):
    '''
    
    '''
    config = {
        'api_sslverify': True,
        'api_url': 'https://INFOBLOX/wapi/v1.2.1',
        'api_user': '',
        'api_key': '',
    }
    if '__salt__' in globals():
        config_key = '{0}.config'.format(__virtualname__)
        config.update(__salt__['config.get'](config_key, {}))
    # pylint: disable=C0201
    for k in set(config.keys()) & set(api_opts.keys()):
        config[k] = api_opts[k]
    return config
992001
def _getConfig(general_config_dir: str = None):
    
    stp_config = STPConfig()
    plenum_config = import_module("plenum.config")
    config = stp_config
    config.__dict__.update(plenum_config.__dict__)

    if general_config_dir:
        config.GENERAL_CONFIG_DIR = general_config_dir

    if not config.GENERAL_CONFIG_DIR:
        raise Exception('GENERAL_CONFIG_DIR must be set')

    extend_with_external_config(config, (config.GENERAL_CONFIG_DIR,
                                         config.GENERAL_CONFIG_FILE))

    # "unsafe" is a set of attributes that can set certain behaviors that
    # are not safe, for example, 'disable_view_change' disables view changes
    # from happening. This might be useful in testing scenarios, but never
    # in a live network.
    if not hasattr(config, 'unsafe'):
        setattr(config, 'unsafe', set())
    return config
586608
def get_config(config_spec):
        """"""
        config_file = None
        if config_spec.startswith("http"):
            # URL: fetch it
            config_file = urllib.urlopen(config_spec)
        else:
            # string: open file with that name
            config_file = open(config_spec)
        config = json.load(config_file)
        # Close any open files
        try:
            config_file.close()
        except:
            pass
        return config
1117813
def get_config(section, option, allow_empty_option=True, default=""):
    '''
    
    '''
    try:
        value = config.get(section, option)
        if value is None or len(value) == 0:
            if allow_empty_option:
                return ""
            else:
                return default
        else:
            return value
    except ConfigParser.NoSectionError:
        return default
627617
def _get_config(**kwargs):
    '''
    
    '''
    config = {
        'box_type': 'sealedbox',
        'sk': None,
        'sk_file': os.path.join(kwargs['opts'].get('pki_dir'), 'master/nacl'),
        'pk': None,
        'pk_file': os.path.join(kwargs['opts'].get('pki_dir'), 'master/nacl.pub'),
    }

    config_key = '{0}.config'.format(__virtualname__)
    try:
        config.update(__salt__['config.get'](config_key, {}))
    except (NameError, KeyError) as e:
        # likely using salt-run so fallback to __opts__
        config.update(kwargs['opts'].get(config_key, {}))
    # pylint: disable=C0201
    for k in set(config.keys()) & set(kwargs.keys()):
        config[k] = kwargs[k]
    return config
776041
def _get_config_file_in_folder(cls, path):
        
        if os.path.isfile(path):
            path = os.path.dirname(path)

        for fn in cls.PROJECT_CONFIG_FILES:
            config = RawConfigParser()
            full_path = os.path.join(path, fn)
            if config.read(full_path) and cls._get_section_name(config):
                return full_path
589054
def get_settings(config_file):
    """"""
    default_settings = {
        'general': {
            'endpoint': 'http://guacamole.antojitos.io/files/',
            'shortener': 'http://t.antojitos.io/api/v1/urls',
        }
    }

    settings = configparser.ConfigParser()
    try:
        settings.read_dict(default_settings)
    except AttributeError:
        # using python 2.7
        for section, options in default_settings.items():
            settings.add_section(section)
            for option, value in options.items():
                settings.set(section, option, value)

    if config_file is not None and os.path.exists(config_file):
        settings.read(config_file)
        return settings
    if os.path.exists(CONFIG_FILE):
        settings.read(CONFIG_FILE)
        return settings
    return settings
964584
def use_config_file(self):
        """"""
        self.config_file = self.find_config_file()
        if self.config_file:
            self.apply_config_file(self.config_file)
24962
def get_config(self, config_filename):
        
        x = pyini.Ini(lazy=True, basepath=os.path.join(self.project_dir, 'apps'))
        for p in reversed(self.apps):
            app_path = get_app_dir(p)
            filename = os.path.join(app_path, config_filename)
            if os.path.exists(filename):
                x.read(filename)

        x.freeze()
        return x
567540
def do_get_config(self, line):
        

        def f(p, args):
            try:
                source = args[0]
            except:
                print("argument error")
                return
            print(p.get_config(source))

        self._request(line, f)