mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-25 19:54:25 +01:00
conf: rename methods to snake case (#523)
This commit is contained in:
parent
03103bea14
commit
d172831805
8
conf.py
8
conf.py
@ -60,7 +60,7 @@ def _log(level, text, *args, logger=None, **kwargs):
|
|||||||
else:
|
else:
|
||||||
world._log_queue.append((level, text))
|
world._log_queue.append((level, text))
|
||||||
|
|
||||||
def validateConf(conf, logger=None):
|
def _validate_conf(conf, logger=None):
|
||||||
"""Validates a parsed configuration dict."""
|
"""Validates a parsed configuration dict."""
|
||||||
validate(isinstance(conf, dict),
|
validate(isinstance(conf, dict),
|
||||||
"Invalid configuration given: should be type dict, not %s."
|
"Invalid configuration given: should be type dict, not %s."
|
||||||
@ -108,7 +108,7 @@ def validateConf(conf, logger=None):
|
|||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
def loadConf(filename, errors_fatal=True, logger=None):
|
def load_conf(filename, errors_fatal=True, logger=None):
|
||||||
"""Loads a PyLink configuration file from the filename given."""
|
"""Loads a PyLink configuration file from the filename given."""
|
||||||
global confname, conf, fname
|
global confname, conf, fname
|
||||||
# Note: store globally the last loaded conf filename, for REHASH in coremods/control.
|
# Note: store globally the last loaded conf filename, for REHASH in coremods/control.
|
||||||
@ -118,7 +118,7 @@ def loadConf(filename, errors_fatal=True, logger=None):
|
|||||||
try:
|
try:
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
conf = yaml.load(f)
|
conf = yaml.load(f)
|
||||||
conf = validateConf(conf, logger=logger)
|
conf = _validate_conf(conf, logger=logger)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
e = 'Failed to load config from %r: %s: %s' % (filename, type(e).__name__, e)
|
e = 'Failed to load config from %r: %s: %s' % (filename, type(e).__name__, e)
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ def loadConf(filename, errors_fatal=True, logger=None):
|
|||||||
else:
|
else:
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
def getDatabaseName(dbname):
|
def get_database_name(dbname):
|
||||||
"""
|
"""
|
||||||
Returns a database filename with the given base DB name appropriate for the
|
Returns a database filename with the given base DB name appropriate for the
|
||||||
current PyLink instance.
|
current PyLink instance.
|
||||||
|
@ -92,7 +92,7 @@ def rehash():
|
|||||||
log.info('Reloading PyLink configuration...')
|
log.info('Reloading PyLink configuration...')
|
||||||
old_conf = conf.conf.copy()
|
old_conf = conf.conf.copy()
|
||||||
fname = conf.fname
|
fname = conf.fname
|
||||||
new_conf = conf.loadConf(fname, errors_fatal=False, logger=log)
|
new_conf = conf.load_conf(fname, errors_fatal=False, logger=log)
|
||||||
conf.conf = new_conf
|
conf.conf = new_conf
|
||||||
|
|
||||||
# Reset any file logger options.
|
# Reset any file logger options.
|
||||||
|
@ -41,7 +41,7 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# FIXME: we can't pass logging on to conf until we set up the config...
|
# FIXME: we can't pass logging on to conf until we set up the config...
|
||||||
conf.loadConf(args.config)
|
conf.load_conf(args.config)
|
||||||
|
|
||||||
from pylinkirc.log import log
|
from pylinkirc.log import log
|
||||||
from pylinkirc import classes, utils, coremods
|
from pylinkirc import classes, utils, coremods
|
||||||
|
@ -17,7 +17,7 @@ reply = modebot.reply
|
|||||||
error = modebot.error
|
error = modebot.error
|
||||||
|
|
||||||
# Databasing variables.
|
# Databasing variables.
|
||||||
dbname = conf.getDatabaseName('automode')
|
dbname = conf.get_database_name('automode')
|
||||||
datastore = structures.JSONDataStore('automode', dbname, default_db=collections.defaultdict(dict))
|
datastore = structures.JSONDataStore('automode', dbname, default_db=collections.defaultdict(dict))
|
||||||
|
|
||||||
db = datastore.store
|
db = datastore.store
|
||||||
|
@ -19,7 +19,7 @@ spawnlocks = defaultdict(threading.RLock)
|
|||||||
spawnlocks_servers = defaultdict(threading.RLock)
|
spawnlocks_servers = defaultdict(threading.RLock)
|
||||||
channels_init_in_progress = defaultdict(threading.Event)
|
channels_init_in_progress = defaultdict(threading.Event)
|
||||||
|
|
||||||
dbname = conf.getDatabaseName('pylinkrelay')
|
dbname = conf.get_database_name('pylinkrelay')
|
||||||
datastore = structures.PickleDataStore('pylinkrelay', dbname)
|
datastore = structures.PickleDataStore('pylinkrelay', dbname)
|
||||||
db = datastore.store
|
db = datastore.store
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user