From d1728318056da85aa7b8e1a8f4116692ce06382d Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 2 Mar 2018 20:22:31 -0800 Subject: [PATCH] conf: rename methods to snake case (#523) --- conf.py | 8 ++++---- coremods/control.py | 2 +- launcher.py | 2 +- plugins/automode.py | 2 +- plugins/relay.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conf.py b/conf.py index c6d1104..7a0a45e 100644 --- a/conf.py +++ b/conf.py @@ -60,7 +60,7 @@ def _log(level, text, *args, logger=None, **kwargs): else: world._log_queue.append((level, text)) -def validateConf(conf, logger=None): +def _validate_conf(conf, logger=None): """Validates a parsed configuration dict.""" validate(isinstance(conf, dict), "Invalid configuration given: should be type dict, not %s." @@ -108,7 +108,7 @@ def validateConf(conf, logger=None): 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.""" global confname, conf, fname # 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: with open(filename, 'r') as f: conf = yaml.load(f) - conf = validateConf(conf, logger=logger) + conf = _validate_conf(conf, logger=logger) except Exception as 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: return conf -def getDatabaseName(dbname): +def get_database_name(dbname): """ Returns a database filename with the given base DB name appropriate for the current PyLink instance. diff --git a/coremods/control.py b/coremods/control.py index 1b6975b..d8f0d80 100644 --- a/coremods/control.py +++ b/coremods/control.py @@ -92,7 +92,7 @@ def rehash(): log.info('Reloading PyLink configuration...') old_conf = conf.conf.copy() 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 # Reset any file logger options. diff --git a/launcher.py b/launcher.py index 766dc49..ed769be 100644 --- a/launcher.py +++ b/launcher.py @@ -41,7 +41,7 @@ def main(): sys.exit(1) # 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 import classes, utils, coremods diff --git a/plugins/automode.py b/plugins/automode.py index 17a0f4b..19411d5 100644 --- a/plugins/automode.py +++ b/plugins/automode.py @@ -17,7 +17,7 @@ reply = modebot.reply error = modebot.error # Databasing variables. -dbname = conf.getDatabaseName('automode') +dbname = conf.get_database_name('automode') datastore = structures.JSONDataStore('automode', dbname, default_db=collections.defaultdict(dict)) db = datastore.store diff --git a/plugins/relay.py b/plugins/relay.py index 1ef418b..d598e06 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -19,7 +19,7 @@ spawnlocks = defaultdict(threading.RLock) spawnlocks_servers = defaultdict(threading.RLock) channels_init_in_progress = defaultdict(threading.Event) -dbname = conf.getDatabaseName('pylinkrelay') +dbname = conf.get_database_name('pylinkrelay') datastore = structures.PickleDataStore('pylinkrelay', dbname) db = datastore.store