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
@ -73,7 +73,7 @@ def describePlugin(module, showUsage):
|
|||||||
pydoc.pager(module.example)
|
pydoc.pager(module.example)
|
||||||
else:
|
else:
|
||||||
output("""This plugin has no usage example.""")
|
output("""This plugin has no usage example.""")
|
||||||
|
|
||||||
def clearLoadedPlugins(plugins, pluginRegistry):
|
def clearLoadedPlugins(plugins, pluginRegistry):
|
||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
try:
|
try:
|
||||||
@ -84,11 +84,11 @@ def clearLoadedPlugins(plugins, pluginRegistry):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
_windowsVarRe = re.compile(r'%(\w+)%')
|
_windowsVarRe = re.compile(r'%(\w+)%')
|
||||||
def getDirectoryName(default):
|
def getDirectoryName(default, basedir=os.curdir):
|
||||||
done = False
|
done = False
|
||||||
while not done:
|
while not done:
|
||||||
dir = something('What directory do you want to use?',
|
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 = os.path.expanduser(dir)
|
||||||
dir = _windowsVarRe.sub(r'$\1', dir)
|
dir = _windowsVarRe.sub(r'$\1', dir)
|
||||||
dir = os.path.expandvars(dir)
|
dir = os.path.expandvars(dir)
|
||||||
@ -183,7 +183,7 @@ def main():
|
|||||||
users. Others might not make sense unless you've used Supybot for some
|
users. Others might not make sense unless you've used Supybot for some
|
||||||
time.""")
|
time.""")
|
||||||
advanced = yn('Are you an advanced Supybot user?', default=False)
|
advanced = yn('Are you an advanced Supybot user?', default=False)
|
||||||
|
|
||||||
### Directories.
|
### Directories.
|
||||||
# We set these variables in cache because otherwise conf and log will
|
# We set these variables in cache because otherwise conf and log will
|
||||||
# create directories for the default values, which might not be what the
|
# create directories for the default values, which might not be what the
|
||||||
@ -206,6 +206,7 @@ def main():
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
logDir = getDirectoryName('logs')
|
logDir = getDirectoryName('logs')
|
||||||
conf.supybot.directories.log.setValue(logDir)
|
conf.supybot.directories.log.setValue(logDir)
|
||||||
|
basedir = os.path.dirname(logDir)
|
||||||
|
|
||||||
# conf.supybot.directories.data
|
# conf.supybot.directories.data
|
||||||
output("""Your bot will need to put various data somewhere. Things like
|
output("""Your bot will need to put various data somewhere. Things like
|
||||||
@ -215,9 +216,9 @@ def main():
|
|||||||
try:
|
try:
|
||||||
dataDir = registry._cache['supybot.directories.data']
|
dataDir = registry._cache['supybot.directories.data']
|
||||||
dataDir = utils.safeEval(dataDir)
|
dataDir = utils.safeEval(dataDir)
|
||||||
dataDir = getDirectoryName(dataDir)
|
dataDir = getDirectoryName(dataDir, basedir=basedir)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
dataDir = getDirectoryName('data')
|
dataDir = getDirectoryName('data', basedir=basedir)
|
||||||
conf.supybot.directories.data.setValue(dataDir)
|
conf.supybot.directories.data.setValue(dataDir)
|
||||||
|
|
||||||
# conf.supybot.directories.conf
|
# conf.supybot.directories.conf
|
||||||
@ -228,11 +229,11 @@ def main():
|
|||||||
try:
|
try:
|
||||||
confDir = registry._cache['supybot.directories.conf']
|
confDir = registry._cache['supybot.directories.conf']
|
||||||
confDir = utils.safeEval(confDir)
|
confDir = utils.safeEval(confDir)
|
||||||
confDir = getDirectoryName(confDir)
|
confDir = getDirectoryName(confDir, basedir=basedir)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
confDir = getDirectoryName('conf')
|
confDir = getDirectoryName('conf', basedir=basedir)
|
||||||
conf.supybot.directories.conf.setValue(confDir)
|
conf.supybot.directories.conf.setValue(confDir)
|
||||||
|
|
||||||
# pluginDirs
|
# pluginDirs
|
||||||
output("""Your bot will also need to know where to find his plugins at.
|
output("""Your bot will also need to know where to find his plugins at.
|
||||||
Of course, he already knows where the plugins that he came with are, but
|
Of course, he already knows where the plugins that he came with are, but
|
||||||
@ -243,7 +244,7 @@ def main():
|
|||||||
output(utils.commaAndify(pluginDirs))
|
output(utils.commaAndify(pluginDirs))
|
||||||
while yn('Would you like to add another plugin directory?',
|
while yn('Would you like to add another plugin directory?',
|
||||||
default=False):
|
default=False):
|
||||||
pluginDir = getDirectoryName('plugins')
|
pluginDir = getDirectoryName('plugins', basedir=basedir)
|
||||||
if pluginDir not in pluginDirs:
|
if pluginDir not in pluginDirs:
|
||||||
pluginDirs.append(pluginDir)
|
pluginDirs.append(pluginDir)
|
||||||
conf.supybot.directories.plugins.setValue(pluginDirs)
|
conf.supybot.directories.plugins.setValue(pluginDirs)
|
||||||
@ -444,14 +445,13 @@ def main():
|
|||||||
if not yn('Would you like add another plugin?'):
|
if not yn('Would you like add another plugin?'):
|
||||||
break
|
break
|
||||||
name = expect('What plugin would you like to look at?', plugins)
|
name = expect('What plugin would you like to look at?', plugins)
|
||||||
|
|
||||||
###
|
###
|
||||||
# Sundry
|
# Sundry
|
||||||
###
|
###
|
||||||
output("""Although supybot offers a supybot-adduser.py script, with which
|
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 can add users to your bot's user database, it's *very* important that
|
||||||
you have an owner user for you bot.""")
|
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):
|
if yn('Would you like to add an owner user for your bot?', default=True):
|
||||||
import ircdb
|
import ircdb
|
||||||
name = something('What should the owner\'s username be?')
|
name = something('What should the owner\'s username be?')
|
||||||
@ -633,7 +633,7 @@ def main():
|
|||||||
except InvalidRegistryValue:
|
except InvalidRegistryValue:
|
||||||
output("""That's not a valid time. You'll need to give
|
output("""That's not a valid time. You'll need to give
|
||||||
a floating-point number.""")
|
a floating-point number.""")
|
||||||
|
|
||||||
###
|
###
|
||||||
# This is close to the end.
|
# This is close to the end.
|
||||||
###
|
###
|
||||||
@ -645,7 +645,7 @@ def main():
|
|||||||
what you'd like to change, then come back and run this script again
|
what you'd like to change, then come back and run this script again
|
||||||
and tell us you're an advanced user. Some of those questions might be
|
and tell us you're an advanced user. Some of those questions might be
|
||||||
boring, but they'll really help you customize your bot :)""")
|
boring, but they'll really help you customize your bot :)""")
|
||||||
|
|
||||||
###
|
###
|
||||||
# Write the registry
|
# Write the registry
|
||||||
###
|
###
|
||||||
@ -654,7 +654,7 @@ def main():
|
|||||||
if not filename:
|
if not filename:
|
||||||
filename = '%s.conf' % nick
|
filename = '%s.conf' % nick
|
||||||
registry.close(conf.supybot, filename)
|
registry.close(conf.supybot, filename)
|
||||||
|
|
||||||
# Done!
|
# Done!
|
||||||
output("""All done! Your new bot configuration is %s. If you're running
|
output("""All done! Your new bot configuration is %s. If you're running
|
||||||
a *nix based OS, you can probably start your bot with the command line
|
a *nix based OS, you can probably start your bot with the command line
|
||||||
|
@ -44,7 +44,7 @@ useBold = False
|
|||||||
|
|
||||||
def output(s, unformatted=True):
|
def output(s, unformatted=True):
|
||||||
if unformatted:
|
if unformatted:
|
||||||
s = textwrap.fill(utils.normalizeWhitespace(s))
|
s = textwrap.fill(utils.normalizeWhitespace(s), width=65)
|
||||||
print s
|
print s
|
||||||
print
|
print
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user