Console cleanup.
This commit is contained in:
parent
6944cc25a0
commit
1f390ffda9
1 changed files with 11 additions and 6 deletions
17
console.py
17
console.py
|
@ -124,14 +124,19 @@ class ConsoleWindow(QtGui.QDialog):
|
||||||
"MAINWIN": self.mainwindow,
|
"MAINWIN": self.mainwindow,
|
||||||
"PCONFIG": self.mainwindow.config
|
"PCONFIG": self.mainwindow.config
|
||||||
}
|
}
|
||||||
|
_CUSTOM_ENV_USE = []
|
||||||
|
cenv = pchum.__dict__
|
||||||
for k in _CUSTOM_ENV:
|
for k in _CUSTOM_ENV:
|
||||||
if k not in env:
|
if k not in cenv:
|
||||||
# Don't overwrite anything!
|
cenv[k] = _CUSTOM_ENV[k]
|
||||||
env[k] = _CUSTOM_ENV[k]
|
_CUSTOM_ENV_USE.append(k)
|
||||||
else:
|
else:
|
||||||
warn = "Console environment item {!r} already exists in main."
|
# Don't overwrite anything!
|
||||||
|
warn = "Console environment item {!r} already exists in CENV."
|
||||||
warn.format(k)
|
warn.format(k)
|
||||||
logging.warning(warn)
|
logging.warning(warn)
|
||||||
|
# Because all we did was change a linked AttrDict, we should be fine
|
||||||
|
# here.
|
||||||
|
|
||||||
# Display the input we provided
|
# Display the input we provided
|
||||||
self.addMessage(scriptstr, 1)
|
self.addMessage(scriptstr, 1)
|
||||||
|
@ -155,9 +160,9 @@ class ConsoleWindow(QtGui.QDialog):
|
||||||
|
|
||||||
# Try to clean us out of globals - this might be disabled
|
# Try to clean us out of globals - this might be disabled
|
||||||
# later.
|
# later.
|
||||||
for k in _CUSTOM_ENV:
|
for k in _CUSTOM_ENV_USED:
|
||||||
# Remove the key we added.
|
# Remove the key we added.
|
||||||
env.pop(k, None)
|
cenv.pop(k, None)
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
# Replaces sys.stdout briefly
|
# Replaces sys.stdout briefly
|
||||||
|
|
Loading…
Reference in a new issue