mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 14:40:51 +01:00
Remember the basedir when we prompt users for their directories and wrap
the prompts a little tighter.
This commit is contained in:
parent
61d6e029b1
commit
233174d9ce
@ -84,11 +84,11 @@ def clearLoadedPlugins(plugins, pluginRegistry):
|
||||
continue
|
||||
|
||||
_windowsVarRe = re.compile(r'%(\w+)%')
|
||||
def getDirectoryName(default):
|
||||
def getDirectoryName(default, basedir=os.curdir):
|
||||
done = False
|
||||
while not done:
|
||||
dir = something('What directory do you want to use?',
|
||||
default=os.path.join(os.curdir, default))
|
||||
default=os.path.join(basedir, default))
|
||||
dir = os.path.expanduser(dir)
|
||||
dir = _windowsVarRe.sub(r'$\1', dir)
|
||||
dir = os.path.expandvars(dir)
|
||||
@ -206,6 +206,7 @@ def main():
|
||||
except KeyError:
|
||||
logDir = getDirectoryName('logs')
|
||||
conf.supybot.directories.log.setValue(logDir)
|
||||
basedir = os.path.dirname(logDir)
|
||||
|
||||
# conf.supybot.directories.data
|
||||
output("""Your bot will need to put various data somewhere. Things like
|
||||
@ -215,9 +216,9 @@ def main():
|
||||
try:
|
||||
dataDir = registry._cache['supybot.directories.data']
|
||||
dataDir = utils.safeEval(dataDir)
|
||||
dataDir = getDirectoryName(dataDir)
|
||||
dataDir = getDirectoryName(dataDir, basedir=basedir)
|
||||
except KeyError:
|
||||
dataDir = getDirectoryName('data')
|
||||
dataDir = getDirectoryName('data', basedir=basedir)
|
||||
conf.supybot.directories.data.setValue(dataDir)
|
||||
|
||||
# conf.supybot.directories.conf
|
||||
@ -228,9 +229,9 @@ def main():
|
||||
try:
|
||||
confDir = registry._cache['supybot.directories.conf']
|
||||
confDir = utils.safeEval(confDir)
|
||||
confDir = getDirectoryName(confDir)
|
||||
confDir = getDirectoryName(confDir, basedir=basedir)
|
||||
except KeyError:
|
||||
confDir = getDirectoryName('conf')
|
||||
confDir = getDirectoryName('conf', basedir=basedir)
|
||||
conf.supybot.directories.conf.setValue(confDir)
|
||||
|
||||
# pluginDirs
|
||||
@ -243,7 +244,7 @@ def main():
|
||||
output(utils.commaAndify(pluginDirs))
|
||||
while yn('Would you like to add another plugin directory?',
|
||||
default=False):
|
||||
pluginDir = getDirectoryName('plugins')
|
||||
pluginDir = getDirectoryName('plugins', basedir=basedir)
|
||||
if pluginDir not in pluginDirs:
|
||||
pluginDirs.append(pluginDir)
|
||||
conf.supybot.directories.plugins.setValue(pluginDirs)
|
||||
@ -451,7 +452,6 @@ def main():
|
||||
output("""Although supybot offers a supybot-adduser.py script, with which
|
||||
you can add users to your bot's user database, it's *very* important that
|
||||
you have an owner user for you bot.""")
|
||||
print '***', conf.supybot.directories.conf()
|
||||
if yn('Would you like to add an owner user for your bot?', default=True):
|
||||
import ircdb
|
||||
name = something('What should the owner\'s username be?')
|
||||
|
@ -44,7 +44,7 @@ useBold = False
|
||||
|
||||
def output(s, unformatted=True):
|
||||
if unformatted:
|
||||
s = textwrap.fill(utils.normalizeWhitespace(s))
|
||||
s = textwrap.fill(utils.normalizeWhitespace(s), width=65)
|
||||
print s
|
||||
print
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user