mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-28 13:42:37 +01:00
Move getDatabaseName from utils to conf (#476)
This commit is contained in:
parent
ff8587736f
commit
43b6566aa8
15
conf.py
15
conf.py
@ -108,7 +108,6 @@ def validateConf(conf, logger=None):
|
||||
|
||||
return conf
|
||||
|
||||
|
||||
def loadConf(filename, errors_fatal=True, logger=None):
|
||||
"""Loads a PyLink configuration file from the filename given."""
|
||||
global confname, conf, fname
|
||||
@ -134,3 +133,17 @@ def loadConf(filename, errors_fatal=True, logger=None):
|
||||
raise
|
||||
else:
|
||||
return conf
|
||||
|
||||
def getDatabaseName(dbname):
|
||||
"""
|
||||
Returns a database filename with the given base DB name appropriate for the
|
||||
current PyLink instance.
|
||||
|
||||
This returns '<dbname>.db' if the running config name is PyLink's default
|
||||
(pylink.yml), and '<dbname>-<config name>.db' for anything else. For example,
|
||||
if this is called from an instance running as './pylink testing.yml', it
|
||||
would return '<dbname>-testing.db'."""
|
||||
if confname != 'pylink':
|
||||
dbname += '-%s' % conf.confname
|
||||
dbname += '.db'
|
||||
return dbname
|
||||
|
@ -17,7 +17,7 @@ reply = modebot.reply
|
||||
error = modebot.error
|
||||
|
||||
# Databasing variables.
|
||||
dbname = utils.getDatabaseName('automode')
|
||||
dbname = conf.getDatabaseName('automode')
|
||||
datastore = structures.JSONDataStore('automode', dbname, default_db=collections.defaultdict(dict))
|
||||
|
||||
db = datastore.store
|
||||
|
@ -18,7 +18,7 @@ relayservers = defaultdict(dict)
|
||||
spawnlocks = defaultdict(threading.RLock)
|
||||
spawnlocks_servers = defaultdict(threading.RLock)
|
||||
|
||||
dbname = utils.getDatabaseName('pylinkrelay')
|
||||
dbname = conf.getDatabaseName('pylinkrelay')
|
||||
datastore = structures.PickleDataStore('pylinkrelay', dbname)
|
||||
db = datastore.store
|
||||
|
||||
|
14
utils.py
14
utils.py
@ -112,20 +112,6 @@ def getProtocolModule(name):
|
||||
"""
|
||||
return importlib.import_module(PROTOCOL_PREFIX + name)
|
||||
|
||||
def getDatabaseName(dbname):
|
||||
"""
|
||||
Returns a database filename with the given base DB name appropriate for the
|
||||
current PyLink instance.
|
||||
|
||||
This returns '<dbname>.db' if the running config name is PyLink's default
|
||||
(pylink.yml), and '<dbname>-<config name>.db' for anything else. For example,
|
||||
if this is called from an instance running as './pylink testing.yml', it
|
||||
would return '<dbname>-testing.db'."""
|
||||
if conf.confname != 'pylink':
|
||||
dbname += '-%s' % conf.confname
|
||||
dbname += '.db'
|
||||
return dbname
|
||||
|
||||
def splitHostmask(mask):
|
||||
"""
|
||||
Returns a nick!user@host hostmask split into three fields: nick, user, and host.
|
||||
|
Loading…
Reference in New Issue
Block a user