mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-03 01:39:23 +01:00
Added support for environment variables in pathnames.
This commit is contained in:
parent
63135c4c48
commit
1a51ced500
@ -5,6 +5,7 @@ import supybot
|
|||||||
import fix
|
import fix
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import sets
|
import sets
|
||||||
import pydoc
|
import pydoc
|
||||||
@ -102,6 +103,7 @@ def clearLoadedPlugins(onStart, plugins):
|
|||||||
if plugin in plugins:
|
if plugin in plugins:
|
||||||
plugins.remove(plugin)
|
plugins.remove(plugin)
|
||||||
|
|
||||||
|
_windowsVarRe = re.compile(r'%(\w+)%')
|
||||||
def getDirectoryName(default):
|
def getDirectoryName(default):
|
||||||
done = False
|
done = False
|
||||||
while not done:
|
while not done:
|
||||||
@ -110,6 +112,8 @@ def getDirectoryName(default):
|
|||||||
if not dir:
|
if not dir:
|
||||||
dir = default
|
dir = default
|
||||||
dir = os.path.expanduser(dir)
|
dir = os.path.expanduser(dir)
|
||||||
|
dir = _windowsVarRe.sub(r'$\1', dir)
|
||||||
|
dir = os.path.expandvars(dir)
|
||||||
dir = os.path.abspath(dir)
|
dir = os.path.abspath(dir)
|
||||||
try:
|
try:
|
||||||
os.makedirs(dir)
|
os.makedirs(dir)
|
||||||
@ -121,7 +125,7 @@ def getDirectoryName(default):
|
|||||||
have to pick someplace else.""" % e)
|
have to pick someplace else.""" % e)
|
||||||
else:
|
else:
|
||||||
done = True
|
done = True
|
||||||
return dir
|
return os.path.expandvars(os.path.expanduser(dir))
|
||||||
|
|
||||||
def myPrint(s, unformatted=True):
|
def myPrint(s, unformatted=True):
|
||||||
if unformatted:
|
if unformatted:
|
||||||
|
Loading…
Reference in New Issue
Block a user