Did I find the right examples for you? yes no

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)
Parse INI file containing configuration details.


        def parse_config_file(path):
    """Parse INI file containing configuration details.

    # Parse options file
    parser = SafeConfigParser(defaults=DEFAULTS)

    with open(path, 'r') as fp:

    # Build a list of label named tuples
    ignore_sections = ['options', 'auth', 'connection']

    sections = [s for s in parser.sections() if s not in ignore_sections]

    labels = [make_label(sec,
                         parser.get(sec, 'min'),
                         parser.get(sec, 'max')) for sec in sections]

    # Build an options object and return it

    opts = dict(
        folder=parser.get('options', 'folder'),
        user=parser.get('auth', 'user'),
        password=parser.get('auth', 'password'),
        host=parser.get('connection', 'host'),
        ssl=parser.getboolean('connection', 'ssl'),
        port=parser.getint('connection', 'port'),
    return opts

src/i/m/IMAPClient-0.10.2/imapclient/interact.py   IMAPClient(Download)
from optparse import OptionParser
from .config import parse_config_file, create_client_from_config
def command_line():
            p.error('If -f/--file is given no other options can be used')
        # Use the options in the config file
        opts = parse_config_file(opts.file)
        # Get compulsory options if not given on the command line

src/w/e/wechat-bot-HEAD/app.py   wechat-bot(Download)
    debug = options.debug
    if not debug:
        options.debug = False

src/w/e/weighmail-0.1.0/weighmail/main.py   weighmail(Download)
    # Read config file if the option was specified
    if config_file is not None:
        opts = config.parse_config_file(config_file)
        opts = config.DEFAULTS

src/i/m/IMAPClient-0.10.2/imapclient/livetest.py   IMAPClient(Download)
from .six import binary_type, text_type, PY3
from .test.util import unittest
from .config import parse_config_file, create_client_from_config
# TODO cleaner verbose output: avoid "__main__" and separator between classes
    if not os.path.isfile(ini_path):
        argv_error('%r is not a livetest INI file' % ini_path)
    host_config = parse_config_file(ini_path)
    return host_config