How to use the configparser.ExtendedInterpolation function in configparser

To help you get started, we’ve selected a few configparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tjcsl / cslbot / scripts / View on Github external
def main(confdir: str = "/etc/cslbot") -> None:
    config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
    with open(path.join(confdir, 'config.cfg')) as f:
    session = get_session(config)()
    parser = argparse.ArgumentParser()
    parser.add_argument('outdir', help='The directory to write logs too.')
    cmdargs = parser.parse_args()
    if not path.exists(cmdargs.outdir):
    lockfile = open(path.join(cmdargs.outdir, '.lock'), 'w')
    fcntl.lockf(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
    current_id = get_id(cmdargs.outdir)
    new_id = session.query(
    # Don't die on empty log table.
    if new_id is None:
        new_id = 0
    save_id(cmdargs.outdir, new_id)
github piranha / nomad / nomad / View on Github external
def get_ini(path):
    fn, path = path.split(':')
    section, key = path.split('.')
    cfg = ConfigParser(interpolation=ExtendedInterpolation())[fn])
        return cfg[section][key]
    except KeyError:
        raise KeyError('%s not found in %s' % (path, fn))
github aaiijmrtt / DEEPSPEECH / code / View on Github external
model['optim'] = getattr(tf.train, config.get('global', 'optim'))(model['lrate']).minimize(model['loss'], global_step = model['step'], name = 'optim')

	return model

def feed(features, labelslen, labelsind, labelsval, batch_size, time_size):
	feed_dict = {model['cnn_inputs']: [[features[i][:, t] if t < labelslen[i] else np.zeros(features[i][:, labelslen[i] - 1].shape, np.float32) for i in xrange(batch_size)] for t in xrange(time_size)]}
	feed_dict.update({model['cnn_in2length']: [features[i].shape[1] for i in xrange(batch_size)], model['ctc_labels_len']: labelslen, model['ctc_labels_ind']: labelsind, model['ctc_labels_val']: labelsval})
	return feed_dict

def handler(signum, stack):
	print, 'saving model prematurely'
	tf.train.Saver().save(sess, os.path.join(config.get('global', 'path'), 'model'))

if __name__ == '__main__':
	config = configparser.ConfigParser(interpolation = configparser.ExtendedInterpolation())[1])
	print, 'creating model'
	model = cldnn(config)

	with tf.Session() as sess:
		signal.signal(signal.SIGINT, handler)
		if sys.argv[2] == 'init':
		elif sys.argv[2] == 'train':
			tf.train.Saver().restore(sess, os.path.join(config.get('global', 'path'), 'model'))
			print, 'training model'
			loss = speechutil.train(model, sess, config, sys.argv[3], feed)
			print, 'trained model', loss
		elif sys.argv[2] == 'test':
			tf.train.Saver().restore(sess, os.path.join(config.get('global', 'path'), 'model'))
			print, 'testing model'
github s390guy / SATK / tools / View on Github external
% (eloc(self,"__init__"),parms)

        self.parms=parms  # Configuration object used by tool
        self.debug=debug  # Whether debug messages are enabled.
        # List of configuration files used by the tool

        # Option/Value delimiters: = :
        # Comment line prefixes: #  ;
        # Inline comments: #

        # List of available sections, updated after each config file is read
        self.sections=[]      # See read_cfg() method
        self.missing=[]       # Requested section but missing
        # Current default setting after reading a new config file
        self.defaults=self.defaults()   # Also, see read_cfg() method
github groboclown / petronia / src / petronia / boot / platform / general / View on Github external
def create_ini_config() -> configparser.ConfigParser:
    Standard configuration.
    ret = configparser.ConfigParser(
    return ret
github tjcsl / cslbot / scripts / View on Github external
def main(confdir: str = "/etc/cslbot") -> None:
    botconfig = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
    with open(join(confdir, 'config.cfg')) as f:
    conf_obj = config.Config()
    conf_obj.set_main_option('bot_config_path', confdir)
    with resources.path('cslbot', botconfig['alembic']['script_location']) as script_location:
        conf_obj.set_main_option('script_location', str(script_location))
        command.upgrade(conf_obj, 'head')
github pjkundert / cpppo / server / enip / View on Github external
# The parser doesn't add a layer of context; run it with a path= keyword to add a layer
    parser			= automata.dfa_post( service, initial=automata.state( 'select' ),
                                                  terminal=True )
    # No config, by default (use default values).  Allows ${<section>:} interpolation, and
    # comments anywhere via the # symbol (this implies no # allowed in any value, due to the lack of
    # support for escape symbol).
    # If config files are desired, somewhere early in program initialization, add:
    # ["", ...] )
    config_loader		= configparser.ConfigParser(
        comment_prefixes=('#',), inline_comment_prefixes=('#',),
        allow_no_value=True, empty_lines_in_values=False,
        interpolation=configparser.ExtendedInterpolation() )

    def register_service_parser( cls, number, name, short, machine ):
        """Registers a parser with the Object.  May be invoked during import; no logging."""

        assert number not in cls.service and name not in cls.service, \
            "Duplicate service #%d: %r registered for Object %s" % ( number, name, cls.__name__ )

        cls.service[number]	= name
        cls.service[name]	= number
        cls.transit[number]	= chr( number ) if sys.version_info[0] &lt; 3 else number
        cls.parser.initial[cls.transit[number]] \
				= automata.dfa( name=short, initial=machine, terminal=True )

    GA_ALL_NAM			= "Get Attributes All"</section>
github 3liz / py-qgis-server / pyqgisserver / View on Github external

import os
import sys
import configparser
import logging
import functools

from typing import Any

getenv = os.getenv

LOGGER = logging.getLogger('SRVLOG')

CONFIG = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())    

def print_config( fp ):
    """ print configuration to file

def load_configuration():
    """ Read configuration file

        Load server configuration from configuration file.
    CONFIG.clear()'loading configuration')
github tjcsl / cslbot / scripts / View on Github external
def main(confdir="/etc/cslbot") -> None:
    config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
    with open(join(confdir, 'config.cfg')) as f:
    passwd = config['auth']['ctrlpass']
    port = config['core']['serverport']
    msg = '%s\nreload' % passwd
        proc =['nc', 'localhost', port],
        output = proc.stdout.splitlines()
        for line in output:
        if output[-1] != "Aye Aye Capt'n":
github uzbl / uzbl / uzbl / View on Github external
def main():
    parser = make_parser()
    args = parser.parse_args()

    args.server_socket = expandpath(args.server_socket)

    # Set default pid file location
    if not args.pid_file:
        args.pid_file = "" % args.server_socket
        args.pid_file = expandpath(args.pid_file)

    config = configparser.ConfigParser(

    # Set default log file location
    if not args.log_file:
        args.log_file = "%s.log" % args.server_socket
        args.log_file = expandpath(args.log_file)

    # Logging setup
    init_logger(args)'logging to %r', args.log_file)

    if args.auto_close:
        logger.debug('will auto close')
        logger.debug('will not auto close')